【发布时间】:2020-07-11 13:46:32
【问题描述】:
我创建了一个 Blazor 应用程序,并在创建 C:\Users\wsn2\Test\Certificates\9Cert.pfx 后在 appsettings.json 中添加了以下 json 配置。 (https://docs.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel?view=aspnetcore-3.1)
{
"Kestrel": {
"Endpoints": {
"Https": {
"Url": "https://*:5005",
"Certificates": {
"Path": "C:\\Users\\wsn2\\Test\\Certificates\\9Cert.pfx",
"Password": "4passWord"
}
}
},
"Certificates": {
"Default": {
"Path": "C:\\Users\\wsn2\\Test\\Certificates\\9Cert.pfx",
"Password": "4passWord"
}
}
}
但是,运行已发布的自包含 kestrel 应用程序时出现以下错误:
[23:40:25 INF] 用户配置文件可用。使用“C:\Users\wsn2\AppData\Local\ASP.NET\DataProtection-Keys”作为密钥存储库和 Windows DPAPI 来加密静态密钥。 [23:40:25 FTL] 无法启动 Kestrel。 Internal.Cryptography.CryptoThrowHelper+WindowsCryptographicException:指定的网络密码不正确。 在 Internal.Cryptography.Pal.CertificatePal.FilterPFXStore(字节 [] rawData,SafePasswordHandle 密码,PfxCertStoreFlags pfxCertStoreFlags) 在 Internal.Cryptography.Pal.CertificatePal.FromBlobOrFile(Byte[] rawData, String fileName, SafePasswordHandle password, X509KeyStorageFlags keyStorageFlags) 在 System.Security.Cryptography.X509Certificates.X509Certificate..ctor(字符串文件名,字符串密码,X509KeyStorageFlags keyStorageFlags) 在 System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(字符串文件名,字符串密码) 在 Microsoft.AspNetCore.Server.Kestrel.KestrelConfigurationLoader.LoadCertificate(CertificateConfig certInfo,字符串端点名称) 在 Microsoft.AspNetCore.Server.Kestrel.KestrelConfigurationLoader.LoadDefaultCert(ConfigurationReader configReader) 在 Microsoft.AspNetCore.Server.Kestrel.KestrelConfigurationLoader.Load() 在 Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.ValidateOptions() 在 Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.StartAsync[TContext](IHttpApplication`1 应用程序,CancellationToken cancelToken) 未处理的异常。 Internal.Cryptography.CryptoThrowHelper+WindowsCryptographicException:指定的网络密码不正确。 在 Internal.Cryptography.Pal.CertificatePal.FilterPFXStore(字节 [] rawData,SafePasswordHandle 密码,PfxCertStoreFlags pfxCertStoreFlags) 在 Internal.Cryptography.Pal.CertificatePal.FromBlobOrFile(Byte[] rawData, String fileName, SafePasswordHandle password, X509KeyStorageFlags keyStorageFlags) 在 System.Security.Cryptography.X509Certificates.X509Certificate..ctor(字符串文件名,字符串密码,X509KeyStorageFlags keyStorageFlags) 在 System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(字符串文件名,字符串密码) 在 Microsoft.AspNetCore.Server.Kestrel.KestrelConfigurationLoader.LoadCertificate(CertificateConfig certInfo,字符串端点名称) 在 Microsoft.AspNetCore.Server.Kestrel.KestrelConfigurationLoader.LoadDefaultCert(ConfigurationReader configReader) 在 Microsoft.AspNetCore.Server.Kestrel.KestrelConfigurationLoader.Load() 在 Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.ValidateOptions() 在 Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.StartAsync[TContext](IHttpApplication`1 应用程序,CancellationToken cancelToken) 在 Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancelToken) 在 Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancelToken) 在 Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost 主机,CancellationToken 令牌) 在 Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost 主机,CancellationToken 令牌) 在 Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost 主机)【问题讨论】:
-
你有解决办法吗?
标签: asp.net-core blazor kestrel-http-server