CngKey.Import(...);在PC上成功但在Web主机上失败 [英] CngKey.Import(...); succeeds on PC but fails on Web host
问题描述
以下行在我的PC上成功运行,但在Web主机的服务器上引发了异常:
The following line succeeds on my PC but throws an exception on a web host's server:
CngKey.Import(EccPrivateBlob, CngKeyBlobFormat.EccPrivateBlob); //EccPrivateBlob is a byte[] that works on my PC.
例外:
System.Security.Cryptography.CryptographicException:发生内部错误
。在
处位于System.Security.Cryptography.CngKey.Import(Byte []
keyBlob,CngKeyBlobFormat格式,CngProvider提供者)处,位于System.Security.Cryptography.CngKey.Import(String
providerName)处。 ..
System.Security.Cryptography.CryptographicException: An internal error occurred. at System.Security.Cryptography.NCryptNative.OpenStorageProvider(String providerName) at System.Security.Cryptography.CngKey.Import(Byte[] keyBlob, CngKeyBlobFormat format, CngProvider provider) at ...
这是安全例外吗?
推荐答案
我能够通过启用 WEBSITE_LOAD_USER_PROFILE = 1
在Azure门户中,如此处所述:
I was able to resolve this by enabling WEBSITE_LOAD_USER_PROFILE = 1
in the Azure portal as mentioned here:
How can I sign a JWT token on an Azure WebJob without getting a CryptographicException?
这篇关于CngKey.Import(...);在PC上成功但在Web主机上失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!