CngKey.Import(…); succeeds on PC but fails on Web host

孤人 提交于 2020-01-03 17:28:15

问题


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.

The exception:

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 ...

Is this a security exception? Is there a way around it?


回答1:


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?



来源:https://stackoverflow.com/questions/18062583/cngkey-import-succeeds-on-pc-but-fails-on-web-host

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!