【发布时间】:2018-09-21 21:52:10
【问题描述】:
我正在开发一个自托管的 .Net Core Rest API,以托管在 Service Fabric 的 Docker 容器中。我无法在 Service Fabric 中配置 SSL/Https。 Http似乎工作。我使用 HttpSys 作为 Web 服务器,而不是 Kestrel,因为我读过它不推荐用于没有反向代理的服务(如 IIS)。
这里是网络服务器代码sn-p。
return WebHost.CreateDefaultBuilder(args)
.UseApplicationInsights()
.UseStartup<Startup>()
.UseHttpSys(
options =>
{
options.Authentication.Schemes = AspNetCore.Server.HttpSys.AuthenticationSchemes.None;
options.Authentication.AllowAnonymous = true;
}
)
.Build();
这里是 ServiceManifest.xml 端点 sn-p。
<Endpoints>
<Endpoint Name="ServiceEndpoint" Protocol="http" Port="80" />
<Endpoint Name="ServiceEndpointHttps" Protocol="https" Port="443" Type="Input" CertificateRef="SSLCertificate" />
</Endpoints>
这是 ApplicationManifest EnvironmentVariable sn-p。
<EnvironmentVariable Name="ASPNETCORE_URLS" Value="https://*:443/;http://*:80/"/>
这是 ApplicationManifest.xml 策略 sn-p。
<Policies>
<ContainerHostPolicies CodePackageRef="Code">
<RepositoryCredentials AccountName="accountname" Password="password" PasswordEncrypted="false" />
<PortBinding ContainerPort="80" EndpointRef="ServiceEndpoint"/>
<PortBinding ContainerPort="443" EndpointRef="ServiceEndpointHttps"/>
</ContainerHostPolicies>
<EndpointBindingPolicy CertificateRef="SSLCertificate" EndpointRef="ServiceEndpointHttps" />
</Policies>
这是 ApplicationManifest.xml 证书 sn-p。
<Certificates>
<EndpointCertificate Name="SSLCertificate" X509FindValue="cert thumbprint"/>
</Certificates>
最初,当我仅在 CurrentUser\My Certificate Store 中拥有 SSL 证书时,我遇到了证书部署问题。我在 LocalMachine\My Certificate Store 中部署证书后解决了它。通过此修复,Service 似乎只能在端口 80 中使用 HTTP 协议,而不是在端口 443 中使用 HTTPS 协议。
Service Fabric Explorer 不显示任何错误,事件日志中也没有错误。我在本地 Service Fabric 和 Azure Service Fabric 实例中都遇到了这个问题。
对此的任何想法/指针将不胜感激。
【问题讨论】:
-
你为服务结构使用什么基础操作系统,Windows 还是 Ubuntu?
-
Service Fabric 使用 Windows 操作系统。
-
检查一下,link,将 linux 容器部署到服务结构。
-
嗨..你有解决方案吗?
标签: docker ssl https .net-core azure-service-fabric