问题
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