aspnetcore docker和.pfx certificate..HOW TO?

时间:2018-01-09 12:44:50

标签: ssl docker asp.net-core

这是我迄今为止在Program.cs中所做的事情

X509Certificate2Collection certs = store.Certificates.Find(X509FindType.FindByThumbprint, envConfiguration["certThumbprint"], true);
X509Certificate2 cert = certs[0];
options.Listen(IPAddress.Any, hostUri.Port, (a => a.UseHttps(cert)));

然后我使用

将我的.pfx文件转换为.crt
openssl pkcs12 -in [yourfile.pfx] -out [certificate.crt]

然后在我的Dockerfile

FROM microsoft/aspnetcore
WORKDIR /app
COPY publish-output/. .
COPY certificates/. /usr/local/share/ca-certificates/
RUN update-ca-certificates
EXPOSE 5003
ENTRYPOINT dotnet <nameOfMyApp>.dll

构建运行良好,没有错误。当我运行它时,启动时没有错误也很好。

这是输出

Content root path: /app
Now listening on: https://0.0.0.0:5003
Application started. Press Ctrl+C to shut down.

但是当我尝试访问localhost:5003时,它给了我这个错误

fail: Microsoft.AspNetCore.Server.Kestrel[0]
      Uncaught exception from the OnConnectionAsync method of an IConnectionAdapter.
System.NotSupportedException: The server mode SSL must use a certificate with the associated private key.

0 个答案:

没有答案