Dockerfile证书问题中的.net Core 2.1

时间:2018-11-22 07:43:45

标签: .net docker asp.net-core-2.1

我正在尝试对.net core 2.1应用进行Dockerise。

我的Dockerfile如下

FROM microsoft/dotnet:2.1.300-sdk AS build-env
WORKDIR /app
COPY . /app/

RUN dotnet publish mysolution.sln -c Release -o /app/out

FROM microsoft/dotnet:2.1-aspnetcore-runtime
WORKDIR /app
COPY --from=build-env /app/out .
ENV ASPNETCORE_ENVIRONMENT='Development'

ENTRYPOINT ["dotnet","mysolution.dll"]

问题是我收到证书错误

CryptographicException: Unix LocalMachine X509Store is limited to the Root and CertificateAuthority stores.
Internal.Cryptography.Pal.StorePal.FromSystemStore(string storeName, StoreLocation storeLocation, OpenFlags openFlags)
System.Security.Cryptography.X509Certificates.X509Store.Open(OpenFlags flags)

然后我决定运行挂载主机证书路径(我在其中安装证书的地方)

docker run -v /etc/ssl/certs/:/etc/ssl/certs/ --name mysolution -p 80:80 xxxxxx/mysolution-api:latest "update-ca-certificates"

我仍然遇到相同的问题

所以 1.如何添加证书?

  1. 我是否需要重启dotnet?如果是,怎么办?

  2. 有更好的方法吗?

谢谢!

0 个答案:

没有答案