azure - 将 IdentityServer 4 部署到 Azure VM 时找不到证书

标签 azure .net-core identityserver4

我在将 IdentityServer 4 (ASP.NET Core 1.1) 部署到 Azure VM (Windows Server 2012 R2) 时遇到此证书问题。

crit: IdentityServer4.Hosting.IdentityServerMiddleware[0]
      Unhandled exception: Internal.Cryptography.CryptoThrowHelper+WindowsCryptographicException: The system cannot find the file specified
         at System.Security.Cryptography.CngKey.Open(String keyName, CngProvider provider, CngKeyOpenOptions openOptions)
         at System.Security.Cryptography.CngKey.Open(String keyName, CngProvider provider)
         at Internal.Cryptography.Pal.CertificatePal.GetPrivateKey[T](Func`2 createCsp, Func`2 createCng)
         at Internal.Cryptography.Pal.CertificatePal.GetRSAPrivateKey()

这将在本地开发计算机上运行,​​但我不明白为什么。我在虚拟机上的“我的(本地计算机)”存储中安装了证书。

任何人都可以帮忙解决这个问题吗?谢谢。

最佳答案

我在这里找到了解决方案:

http://www.daves-blog.net/post/2014/06/16/X509Certificate-The-System-cannot-find-the-file-specified.aspx

显然,我需要在应用程序池上启用加载用户配置文件。然而,错误现在变成了这样:

crit: IdentityServer4.Hosting.IdentityServerMiddleware[0]
  Unhandled exception: Internal.Cryptography.CryptoThrowHelper+WindowsCryptographicException: Keyset does not exist
     at System.Security.Cryptography.CngKey.Open(String keyName, CngProvider provider, CngKeyOpenOptions openOptions)
     at System.Security.Cryptography.CngKey.Open(String keyName, CngProvider provider)
     at Internal.Cryptography.Pal.CertificatePal.GetPrivateKey[T](Func`2 createCsp, Func`2 createCng)
     at Internal.Cryptography.Pal.CertificatePal.GetRSAPrivateKey()

现在看看这个问题。

好的,所以问题是读取证书的权限。我们所要做的只是转到证书并授予 IIS_IUSRS 的读取()权限。

现在可以了。

关于azure - 将 IdentityServer 4 部署到 Azure VM 时找不到证书,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44643663/

相关文章:

.net-core - 无法将 Serilog 与 .Net Core 3 IHostBuilder 一起使用

c# - 使用 JSON 格式正确配置 NLog 到 IHostBuilder

c# - IdentityServer4 AddSigningCredentials 与证书

azure - WinDbg !heap 命令在 Windows Azure 上不起作用

azure - 使用 Azure Key Vault 证书解密返回错误

c# - 对包含两个项目的列表进行排序并在 C# 中转换为大写的错误结果

asp.net-core - 是否可以将 NoSQL 用于 Identity Server 4?

asp.net-mvc - Azure 可扩展环境中的 WebSocket

azure - 无论如何,是否可以使用 Bicep 或 ARM 将 PFX SSL 证书文件作为证书导入到 Azure Key Vault

docker - 具有多个实例的IdentityServer4