RSACryptoServiceProvider

Posted by Gow.Net under ASP.NET on 10/10/2012 | Points: 10 | Views : 1424 | Status : [Member] | Replies : 0
I have problem with Encryption and Decryption of a text file using machine key store method keys in RSACryptoServiceProvider through IIS hosting. Actually it works in default developer server. The problem is in hosted website.

Exception is:


at System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr)
at System.Security.Cryptography.Utils._CreateCSP(CspParameters param, Boolean randomKeyContainer, SafeProvHandle& hProv)
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.RSACryptoServiceProvider..ctor(CspParameters parameters)
at CloudStorage.App_Code.Foundation.RSADecryption.AssignParameters() in c:\Hosting\CloudStorage\App_Code\Foundation\RSADecryption.cs:line 31
at CloudStorage.App_Code.Foundation.RSADecryption.DecryptData(String inputString, String SK_Path) in c:\Hosting\CloudStorage\App_Code\Foundation\RSADecryption.cs:line 58
at user_inbox.fileReader(String SK_Path) in c:\Hosting\CloudStorage\user_inbox.aspx.cs:line 116
at user_inbox.btnPVT_Upload_Click(Object sender, EventArgs e) in c:\Hosting\CloudStorage\user_inbox.aspx.cs:line 68

My Code is:

CspParameters cspParams = new CspParameters(1);
cspParams.ProviderName = "Microsoft Strong Cryptographic Provider";
cspParams.KeyContainerName = "Cloud_Key_Container";
cspParams.Flags = CspProviderFlags.UseMachineKeyStore;
rsa = new RSACryptoServiceProvider(cspParams);

gowthaman8870226416


Responses

(No response found.)

Login to post response