在ASP.NET Core样板模板(DotNet Core)的第一次运行时,我从VisualStudio2017获得了有关DotNet证书的以下错误消息:
"Internal.Cryptography.CryptoThrowHelper.WindowsCryptographicException已发生HResult=0x80070002 Message=The系统找不到指定的Source=文件 Internal.Cryptography.Pal.CertificatePal.FromBlobOrFile(Byte[] rawData,String fileName,String password,X509KeyStorageFlags keyStorageFlags) at System.Security.Cryptography.X509Certificates.X509Certificate..ctor(String fileName,String password,X509KeyStorageFlags keyStorageFlags) at Microsoft.AspNetCore.Hosting.KestrelServerOptionsHttpsExtensions.UseHttps(KestrelServerOptions options,String fileName,String密码).“
所有其他使用SSL的项目都可以正常工作,我已经再次检查本地计算机的本地主机证书是否在受信任的根证书颁发机构中,并且没有过期。这个项目正在运行IISExpress --也许它看上去不对?我没有把握。知道我哪里出问题了吗?
发布于 2017-09-19 03:30:34
最近,ASP.NET Core样板也出现了同样的问题。
关闭Visual,右键单击“以管理员身份运行”。为我工作过。
发布于 2017-05-15 15:15:07
两个问题中的一个正在发生。
1)文件“存在”,但它是一个符号链接。这往往会混淆底层系统。(响应是执行File.ReadAllBytes并使用byte[]构造函数)。
2)文件不存在。
为了帮助诊断#2,您可以阅读Environment.CurrentDirectory以了解“这里”的位置,并使用Directory.EnumerateFiles()查看目录中存在的内容以及文件不存在的原因。
当然,如果您不认为您是通过文件加载的,但认为您是从证书存储区加载的:请检查您的配置,然后再试一次.因为您正在从文件中加载:)。
发布于 2020-04-26 12:23:13
如果您在docker中运行,另一个解决方法是在启动时执行副本。
# The copy is done, because wildcard_certificate.pfx is put into the container using docker secrets, which makes it a symlink.
# Reading a certificate as a symlink is not supported at this moment: https://stackoverflow.com/q/43955181/1608705
# After doing a copy, the copied version is not a symlink anymore.
ENTRYPOINT (IF EXIST "c:\certificates\wildcard_certificate.pfx" (copy c:\certificates\wildcard_certificate.pfx c:\app\wildcard_certificate.pfx)) && dotnet webapplication.dll我的应用程序在"c:\app“文件夹中运行,我将”要复制“的证书放在”c:\证书“中。启动时,证书被复制到"c:\app",我的环境变量指向该文件。
version: "3.7"
services:
webapplication:
image: ({CONTAINER_REGISTRY})/webapplication:({LABEL})
environment:
- ASPNETCORE_URLS=https://+;http://+
- ASPNETCORE_HTTPS_PORT=443
- ASPNETCORE_Kestrel__Certificates__Default__Path=wildcard_certificate.pfx
secrets:
- source: config_secrets
target: C:/app/appsettings.json
- source: wildcard_certificate_pfx
target: c:\certificates\wildcard_certificate.pfxhttps://stackoverflow.com/questions/43955181
复制相似问题