Reputation: 21
I have a MVC .Net 4.6.2 Web application that uses the following code to get an RSACryptoServiceProvider:
public static RSACryptoServiceProvider GetKey(byte[] key, string pass)
{
Org.BouncyCastle.Crypto.AsymmetricKeyParameter asp = Org.BouncyCastle.Security.PrivateKeyFactory.DecryptKey(pass.ToCharArray(), key);
var rsa = DotNetUtilities.ToRSA((RsaPrivateCrtKeyParameters)asp) as RSACryptoServiceProvider;
return rsa;
}
On my Web server using IIS, it works correctly.
When I publish in the Azure portal the DecryptKey
method returns the following error:
The system can not find the specified file.
Any ideas?
Upvotes: 1
Views: 310
Reputation: 21
In this operation:
var asp = Org.BouncyCastle.Security.PrivateKeyFactory.DecryptKey(pass.ToCharArray(), key);
BouncyCastle required access to the server's KeyChange, the solution is to add a Configuration setting in Azure Portal.
The following can be added in the Advanced Edit for the Application Settings:
{
"name": "WEBSITE_LOAD_CERTIFICATES",
"value": "1",
"slotSetting": false
}
Or you can add it using the standard Settings editor like in the below screenshots:
Upvotes: 1