This project is read-only.

CryptographicException while Kigg is running

Apr 10, 2009 at 7:07 AM
Sometimes I'm getting an e-mail with this strange exception. I cannot figure out what is triggering this because I can't reproduce it. Any thoughts?

Type : System.Security.Cryptography.
CryptographicException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Message : Bad Data.

Source : mscorlib
Help link :
Data : System.Collections.ListDictionaryInternal
TargetSite : Void ThrowCryptogaphicException(Int32)
Stack Trace :    at System.Security.Cryptography.CryptographicException.ThrowCryptogaphicException(Int32 hr)
  at System.Security.Cryptography.Utils._DecryptData(SafeKeyHandle hKey, Byte[] data, Int32 ib, Int32 cb, Byte[]& outputBuffer, Int32 outputOffset, PaddingMode PaddingMode, Boolean fDone)
  at System.Security.Cryptography.CryptoAPITransform.TransformFinalBlock(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount)
  at System.Security.Cryptography.CryptoStream.FlushFinalBlock()
  at System.Web.Configuration.MachineKeySection.EncryptOrDecryptData(Boolean fEncrypt, Byte[] buf, Byte[] modifier, Int32 start, Int32 length, IVType ivType, Boolean useValidationSymAlgo)
  at System.Web.UI.Page.DecryptStringWithIV(String s, IVType ivType)
  at System.Web.Handlers.AssemblyResourceLoader.System.Web.IHttpHandler.ProcessRequest(HttpContext context)
  at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
  at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Apr 10, 2009 at 10:34 AM
Do you have any value in machineKey section of web.config?
Apr 10, 2009 at 5:24 PM
Hi Kazi,

Yes. I have both validationKey and decryptionKey set. But they are as they were in Kigg. Maybe I should changed them to something else?

Kind regards,
Pawel Lukasik
Apr 15, 2009 at 2:58 PM
Maybe you can the remove the node completely and try again.
Apr 15, 2009 at 4:44 PM
I will give it a try. But what is it used for?
Apr 15, 2009 at 11:49 PM
Edited Apr 15, 2009 at 11:50 PM
Well that is a standard ASP.NET Practice if are planning to host it behind a load balancer though I am not sure the usage on ASP.NET MVC app, may be the AntiForgeryToken use it.
Apr 18, 2009 at 3:03 PM
I commended this line out. Now the exception reads:

Timestamp: 2009-04-18 13:57:00
 Message: HandlingInstanceID: cc897535-da9b-45ac-b289-
63a98916f673
An exception of type 'System.Security.Cryptography.CryptographicException' occurred and was caught.
---------------------------------------------------------------------------------------------------
04/18/2009 15:57:00
Type : System.Security.Cryptography.CryptographicException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Message : Padding is invalid and cannot be removed.
Source : mscorlib
Help link :
Data : System.Collections.ListDictionaryInternal
TargetSite : Int32 DecryptData(Byte[], Int32, Int32, Byte[] ByRef, Int32, System.Security.Cryptography.PaddingMode, Boolean)
Stack Trace :    at System.Security.Cryptography.RijndaelManagedTransform.DecryptData(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount, Byte[]& outputBuffer, Int32 outputOffset, PaddingMode paddingMode, Boolean fLast)
  at System.Security.Cryptography.RijndaelManagedTransform.TransformFinalBlock(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount)
  at System.Security.Cryptography.CryptoStream.FlushFinalBlock()
  at System.Web.Configuration.MachineKeySection.EncryptOrDecryptData(Boolean fEncrypt, Byte[] buf, Byte[] modifier, Int32 start, Int32 length, IVType ivType, Boolean useValidationSymAlgo)
  at System.Web.UI.Page.DecryptStringWithIV(String s, IVType ivType)
  at System.Web.Handlers.AssemblyResourceLoader.System.Web.IHttpHandler.ProcessRequest(HttpContext context)
  at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
  at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Still no idea when this happens. Any ideas?
Apr 23, 2009 at 1:08 PM
I uncommented the line agian. The 'Padding invalid' exception was occuring much more frequently. But stil I have no idea how to solve that. You don't see those exceptions in dotnetshoutout?