我在将 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()
这将在本地开发计算机上运行,但我不明白为什么。我在虚拟机上的“我的(本地计算机)”存储中安装了证书。
任何人都可以帮忙解决这个问题吗?谢谢。
最佳答案
我在这里找到了解决方案:
显然,我需要在应用程序池上启用加载用户配置文件。然而,错误现在变成了这样:
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/