Web developers wiki ASP.NET Sitecore Sharepoint Kentico by Evident Interactive

System.Security.Cryptography.CryptographicException

Modified: 2010/03/04 11:51 by mark - Categorized as: Sitecore
Exception Details:

System.Security.Cryptography.CryptographicException: Padding is invalid and cannot be removed.

Stack Trace:

System.Security.Cryptography.RijndaelManagedTransform.DecryptData System.Security.Cryptography.RijndaelManagedTransform.TransformFinalBlock

Problem definition and solution: This error may occur when you browsed another web site and it stored some cookies that cannot be decrypted by the current application.

Please clear your browser's cache and cookies, restart IIS and the browser to fix this exception.

In addition, please check that the Load User Profile setting of app pool is set to “true”.

Please check the following articles for details: http://blogs.iis.net/bills/archive/2006/10/18/loadUserProfile-and-IIS7-_2D00_-understanding-temporary-directory-failures.aspx http://blogs.msdn.com/vijaysk/archive/2009/03/08/iis-7-tip-3-you-can-now-load-the-user-profile-of-the-application-pool-identity.aspx

Exception Details:

System.Security.Cryptography.CryptographicException: The system cannot find the file specified.

Stack Trace:

System.Security.Cryptography.Utils.CreateProvHandle System.Security.Cryptography.DSACryptoServiceProvider.ImportParameters System.Security.Cryptography.DSA.FromXmlString

Problem definition and solution:

The problem is caused by an issue with the Windows crypto service provider, used by Sitecore to perform a license check.

Please add the following code into the ..\WebSite\global.asax file to work around this exception:

public void Application_Start() { System.Security.Cryptography.RSACryptoServiceProvider.UseMachineKeyStore = true; System.Security.Cryptography.DSACryptoServiceProvider.UseMachineKeyStore = true; }

Exception Details:

System.Security.Cryptography.CryptographicException: Access is denied.

Stack Trace:

System.Security.Cryptography.CryptographicException.ThrowCryptogaphicException System.Security.Cryptography.Utils._CreateCSP System.Security.Cryptography.Utils.CreateProvHandle

or

Exception Details:

System.Security.Cryptography.CryptographicException: Keyset does not exist.

StackTrace:

System.Security.Cryptography.CryptographicException.ThrowCryptogaphicException System.Security.Cryptography.SafeKeyHandle._FreeHKey System.Security.Cryptography.SafeKeyHandle.ReleaseHandle

Problem definition and solution: The application may be trying to write to the following folder:

C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\MachineKeys

If your application uses impersonation or the IUSR_MACHINENAME user, then configure the MachineKeys folder security rights and give the following rights to the user:

Read & Execute, List Folder Contents, Read, Write

If that doesn't work, try giving the same permissions to the Everyone user.

More info: http://sdn.sitecore.net/Scrapbook/Fixing%20Cryptographic%20Errors.aspx

 © Evident Interactive BV