Error on Decrypt Method

  • Thread starter Rodrigo m. Ferreira
  • Start date
R

Rodrigo m. Ferreira

Hi,

i'm using encrypt and decrypt formaauthentication methods, the problem is
that when decrypting a ticket stored on a persistent cookie, it gives an
error, but only if i wait half an hour between two acess.
I notice that this may be a problem with my server, cause its running under
windows server 2007. I notice that because i put the same appplication on a
server that runs under windows server 2003 and it doesn't happen. On the
localhost it goes everything ok too.

Can you help me?

here is the problem:


Server Error in '/outtacom' Application.
--------------------------------------------------------------------------------

Padding is invalid and cannot be removed.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

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

Source Error:

An unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can
be identified using the exception stack trace below.

Stack Trace:


[CryptographicException: Padding is invalid and cannot be removed.]
System.Security.Cryptography.RijndaelManagedTransform.DecryptData(Byte[]
inputBuffer, Int32 inputOffset, Int32 inputCount, Byte[]& outputBuffer,
Int32 outputOffset, PaddingMode paddingMode, Boolean fLast) +1545747
System.Security.Cryptography.RijndaelManagedTransform.TransformFinalBlock(Byte[]
inputBuffer, Int32 inputOffset, Int32 inputCount) +257
System.Security.Cryptography.CryptoStream.FlushFinalBlock() +30
System.Web.Configuration.MachineKeySection.EncryptOrDecryptData(Boolean
fEncrypt, Byte[] buf, Byte[] modifier, Int32 start, Int32 length, Boolean
useValidationSymAlgo) +164
System.Web.Security.FormsAuthentication.Decrypt(String encryptedTicket)
+242
AdminSite.Global.Session_Start(Object sender, EventArgs e) in
Global.asax.cs:29
System.Web.SessionState.SessionStateModule.RaiseOnStart(EventArgs e)
+2221855
System.Web.SessionState.SessionStateModule.CompleteAcquireState() +159
System.Web.SessionState.SessionStateModule.BeginAcquireState(Object
source, EventArgs e, AsyncCallback cb, Object extraData) +518
System.Web.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
+90
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&
completedSynchronously) +161
 
B

bruce barker

by default the encryption key is regenerated on an appdomain recycle.
this means data encrypted with the old key can not be decrypted.

you can specify a fixed key in the web config to allow the key to
persist over recycles. see:

http://msdn.microsoft.com/en-us/library/ms998288.aspx

-- bruce (sqlwork.com)
Hi,

i'm using encrypt and decrypt formaauthentication methods, the problem
is that when decrypting a ticket stored on a persistent cookie, it gives
an error, but only if i wait half an hour between two acess.
I notice that this may be a problem with my server, cause its running
under windows server 2007. I notice that because i put the same
appplication on a server that runs under windows server 2003 and it
doesn't happen. On the localhost it goes everything ok too.

Can you help me?

here is the problem:


Server Error in '/outtacom' Application.
--------------------------------------------------------------------------------


Padding is invalid and cannot be removed.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

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

Source Error:

An unhandled exception was generated during the execution of the current
web
request. Information regarding the origin and location of the exception can
be identified using the exception stack trace below.

Stack Trace:


[CryptographicException: Padding is invalid and cannot be removed.]
System.Security.Cryptography.RijndaelManagedTransform.DecryptData(Byte[]
inputBuffer, Int32 inputOffset, Int32 inputCount, Byte[]& outputBuffer,
Int32 outputOffset, PaddingMode paddingMode, Boolean fLast) +1545747

System.Security.Cryptography.RijndaelManagedTransform.TransformFinalBlock(Byte[]

inputBuffer, Int32 inputOffset, Int32 inputCount) +257
System.Security.Cryptography.CryptoStream.FlushFinalBlock() +30
System.Web.Configuration.MachineKeySection.EncryptOrDecryptData(Boolean
fEncrypt, Byte[] buf, Byte[] modifier, Int32 start, Int32 length, Boolean
useValidationSymAlgo) +164
System.Web.Security.FormsAuthentication.Decrypt(String encryptedTicket)
+242
AdminSite.Global.Session_Start(Object sender, EventArgs e) in
Global.asax.cs:29
System.Web.SessionState.SessionStateModule.RaiseOnStart(EventArgs e)
+2221855
System.Web.SessionState.SessionStateModule.CompleteAcquireState() +159
System.Web.SessionState.SessionStateModule.BeginAcquireState(Object
source, EventArgs e, AsyncCallback cb, Object extraData) +518

System.Web.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()

+90
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&
completedSynchronously) +161
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top