Search code examples
c#asp.netiisrsacryptoserviceprovider

Showing 'Server was unable to process request. ---> Invalid provider type specified.\n' for RSACryptoServiceProvider


I'm using RSA algorithm for encryption and decryption.

X509Certificate2 certificate = new 
X509Certificate2(pfxFilePath,password);
RSACryptoServiceProvider publicKey = (RSACryptoServiceProvider)certificate.PublicKey.Key;

Working properly on local-machine/service but showing Invalid provider type specified.\n' on sever machine.Using same .net framework. How can resolve the issue.


Solution

  • By adding some parameters works in certificate works for me.

    X509Certificate2 certificate = new X509Certificate2(pfxFilePath,password, X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.Exportable);