我有一个 .NET Core Web API 作为 Pod 托管在 Kubernetes 中。它也作为服务公开。 我创建了一个 Dev SSL 证书,并生成了一个 aspnetapp.pfx 文件。
这是我的 Docker 文件的片段:
FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
WORKDIR /app
EXPOSE 443
ENV ASPNETCORE_URLS=https://+:443
ENV ASPNETCORE_HTTPS_PORT=443
ENV ASPNETCORE_Kestrel__Certificates__Default__Password={password}
ENV ASPNETCORE_Kestrel__Certificates__Default__Path=APIGateway/Certificates/aspnetapp.pfx
当我在 Kubernetes 中运行应用程序时,我在容器日志中收到错误,并且容器无法启动:
error:2006D002:BIO routines:BIO_new_file:system lib
我知道它能够找到 SSL 证书,但是它会抛出上述错误。
请帮忙!:)
最佳答案
我刚刚遇到了同样的问题,即使之前一切正常,某些内容已更新(可能是 .NET 6.0.402),这导致了问题。
我注意到 Docker 容器中导出的开发证书 pfx 的权限设置为:
-rw------- 1 root root 2383 Oct 18 14:40 cert.pfx
在我的 Dockerfile 中,我导出 dotnet dev 证书并运行 chmod 为每个人添加读取权限:
RUN dotnet dev-certs https --clean && dotnet dev-certs https --export-path /app/publish/cert.pfx -p {password}
RUN chmod 644 /app/publish/cert.pfx
这导致了与我的应用程序设置文件相同的权限:
-rw-r--r-- 1 root root 535 Oct 18 14:11 appsettings.Development.json
-rw-r--r-- 1 root root 331 Sep 27 18:13 appsettings.json
-rw-r--r-- 1 root root 2383 Oct 18 14:40 cert.pfx
这为我解决了错误。
关于linux - 错误:2006D002:BIO routines:BIO_new_file:system lib,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67725801/