【发布时间】:2019-02-26 16:15:29
【问题描述】:
在 Windows docker 容器中运行 ASP.NET Core 时出现此错误...
Unhandled Exception: System.InvalidOperationException: Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found.
我能够让它工作......
RUN dotnet dev-certs https
但我想安装一个实际的证书...现在是自签名证书,但后来是真实的。
因此,根据题为“使用 Powershell 在 Windows 容器中导入和绑定 SSL 证书”的博文,我创建了以下 PS 脚本以在容器构建中运行...
Import-PfxCertificate -FilePath C:\Certificates\xxx.pfx -Password (ConvertTo-SecureString -String "xxxx" -AsPlainText -Force) `
-CertStoreLocation "Cert:\LocalMachine\My"
$cert = (Get-ChildItem -Path cert:\LocalMachine\My -DNSName "xxx.mydomain.com")[0]
$thumb = ($cert | Select-Object Thumbprint)."Thumbprint"
$guid = [guid]::NewGuid().ToString("B")
netsh http add sslcert ipport=0.0.0.0:5001 certhash=$thumb certstorename=MY appid="$guid"
这构建良好,似乎安装了证书。但是当我尝试运行容器时出现异常。我尝试使用 443 而不是 5001,同样的错误
这是我的 docker 文件供参考...
escape=`
FROM xxx/base
EXPOSE 5000
EXPOSE 5001
COPY testing/ /testing
COPY service/ /Service
COPY certificates/ /certificates
COPY scripts/ /scripts
# install certificates
RUN scripts/Install-Container-Certificate.ps1
# configure ASP.NET Core
ENV ASPNETCORE_URLS http://+:80;https://+:443
EXPOSE 80
EXPOSE 443
# RUN dotnet dev-certs https
# start ASP.NET Core
ENTRYPOINT ["dotnet","/Service/xxxService.dll"]
我做错了什么?
【问题讨论】:
-
本身不是一个答案,但遇到了同样的问题,这里有一些有趣的信息:github.com/dotnet/dotnet-docker/issues/630 和这里github.com/aspnet/AspNetCore.Docs/issues/6199
标签: powershell docker asp.net-core