I have a WCF Web Services in Azure App Service , this WCF use a dll with RSA objects, WCF and dll were build in .NET Framework and C#. I tried use:
RSACryptoServiceProvider rsaCryptoServiceProviderPrivateKey = (RSACryptoServiceProvider)p_x509Certificate2.PrivateKey;
and:
RSA rsaPrivateKey = p_x509Certificate2.GetRSAPrivateKey();
but I have this error:
System.Security.Cryptography.CryptographicException: Invalid provider type specified.
at System.Security.Cryptography.Utils.CreateProvHandle(CspParameters parameters, Boolean randomKeyContainer)
at System.Security.Cryptography.Utils.GetKeyPairHelper(CspAlgorithmType keyType, CspParameters parameters, Boolean randomKeyContainer, Int32 dwKeySize, SafeProvHandle& safeProvHandle, SafeKeyHandle& safeKeyHandle)
at System.Security.Cryptography.RSACryptoServiceProvider.GetKeyPair()
at System.Security.Cryptography.RSACryptoServiceProvider..ctor(Int32 dwKeySize, CspParameters parameters, Boolean useDefaultKeySize)
at System.Security.Cryptography.X509Certificates.X509Certificate2.get_PrivateKey()
The Azure App Service configuration:
How I can fix this problem?
Note: I only use X509Certificate2 file content, I do not have a file .pfx or .p12 in a physically store.
Thanks.