WebResource.axd要解密的数据长度无效

时间:2011-02-08 15:53:45

标签: asp.net webresource.axd

我在事件查看器中有很多错误,看起来像这样。我已经调查了所有可能的解决方案,但仍未找到有效的解决方案;

该网站是网络农场的一部分;会话状态存储在状态服务器中; machinekey在所有服务器上都是一样的;我甚至使用iiscfg在所有服务器上复制iis设置......仍然没有成功;在IIS中,在网站的属性上,我确保“axd mappings”未选中“验证文件是否存在”...

我尝试在httpsndlers中添加以下行:

<add path="WebResource.axd" verb="GET" type="System.Web.Handlers.AssemblyResourceLoader" validate="True" />

但仍未成功......

我真的不知道如何摆脱这个错误。如果有人可以帮助我,我会建议它!

整个堆栈跟踪是:

 Request URL: http://xxxxxxx/WebResource.axd?d=Nu8EdkxldHhw5_nYPoeh3y1EbfLckWGua0HevmQkJr6irkrdL4WYMMP0l2yqOwM7Sd85LYeggTTTURTygkW9tqcBk1Q1&t=634242073212638436 
    Request path: /WebResource.axd 


 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)

4 个答案:

答案 0 :(得分:3)

我终于设法解决了这些错误......这是一个安全更新,它没有安装在所有服务器上,导致加密提供不同的值,即使所有服务器上的机器密钥都相同。

已安装,现在没问题

答案 1 :(得分:1)

希望在此问题和一些搜索字词中添加更多详细信息!

该问题表现为对WebResource.axd和ScriptResource.axd的请求的ASP.Net错误,例如:

HTTP // mysite的/所有MyApplication / WebResource.axd的d = 966IInUloJ ...&安培;ΔT= 6332662 ...

这将导致以这种方式提供的图像,脚本,样式表和其他资源失败。您会注意到查询字符串上的'd'参数在某些主机上会有​​所不同,尽管具有相同的validationKey等等......修复后,您可以在所有主机上测试相同的查询字符串。


'/ MyApplication'应用程序中的服务器错误。

要解密的数据长度无效。

描述:在执行当前Web请求期间发生了未处理的异常。请查看堆栈跟踪,以获取有关错误及其在代码中的起源位置的更多信息。

异常详细信息: System.Security.Cryptography.CryptographicException:要解密的数据长度无效。

来源错误:

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.


堆栈追踪:

[CryptographicException: Length of the data to decrypt is invalid.]
   System.Security.Cryptography.RijndaelManagedTransform.TransformFinalBlock(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount) +7588941
   System.Security.Cryptography.CryptoStream.FlushFinalBlock() +33
   System.Web.Configuration.MachineKeySection.EncryptOrDecryptData(Boolean fEncrypt, Byte[] buf, Byte[] modifier, Int32 start, Int32 length, IVType ivType, Boolean useValidationSymAlgo) +225
   System.Web.UI.Page.DecryptStringWithIV(String s, IVType ivType) +85
   System.Web.Handlers.AssemblyResourceLoader.System.Web.IHttpHandler.ProcessRequest(HttpContext context) +179
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75


版本信息: Microsoft .NET Framework版本:2.0.50727.5653; ASP.NET版本:2.0.50727.4444


在Windows事件日志中,您可能会看到错误:


Event Type:   Warning
Event Source: ASP.NET 2.0.50727.0
Event Category:      Web Event 
Event ID:     1309
Date:         5/23/2011
Time:         3:31:13 PM
User:         N/A
Computer:     MYHOST
Description:
Event code: 3005 
Event message: An unhandled exception has occurred. 
Event time: 5/23/2011 3:31:13 PM 
Event time (UTC): 5/23/2011 7:31:13 AM 
Event ID: a66bd05b39c34da6bc3bfd349aefdf24 
Event sequence: 71 
Event occurrence: 21 
Event detail code: 0 

Application information: 
    Application domain: /LM/W3SVC/98/Root/MyApplication... 
    Trust level: Full 
    Application Virtual Path: /MyApplication
    Application Path: d:\inetpub\mysite\MyApplication\ 
    Machine name: MYHOST 

Process information: 
    Process ID: 15328 
    Process name: w3wp.exe 
    Account name: NT AUTHORITY\NETWORK SERVICE 

Exception information: 
    Exception type: CryptographicException 
    Exception message: Length of the data to decrypt is invalid. 

Request information: 
    Request URL: http://mysite/MyApplication/ScriptResource.axd?d=...&t=...

    Request path: /MyApplication/ScriptResource.axd 
    User host address: 1.1.1.1
    User:  
    Is authenticated: False 
    Authentication Type:  
    Thread account name: NT AUTHORITY\NETWORK SERVICE 

Thread information: 
    Thread ID: 9 
    Thread account name: NT AUTHORITY\NETWORK SERVICE 
    Is impersonating: False 
    Stack trace:    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.UI.Page.DecryptString(String s)

相关更新为 MS10-070 。即使您认为它已安装,您也可能需要重新安装它以修复随后更改的库或其他内容。

此更新中的注意事项为 KB2431728 - Encrypted content in ASP.NET is not decrypted or results in errors for a website that uses persisted Forms Authentication cookies or is deployed in a web farm - 请参阅详细信息。

  

中的一些服务器或应用程序   Web场可能遇到一个或多个   以下症状:......例外情况   在WebResource或ScriptResource中   处理

...

  

该公告的安全更新   MS10-070   (http://www.microsoft.com/technet/security/bulletin/ms10-070.mspx)   地址更改默认行为   ASP.NET中的加密。

...

  

为ASP.NET提供服务的所有服务器   网络农场的网站必须   安装安全更新。如果有的话   服务器没有安全性   更新已安装,您必须申请   更新到这些服务器。

答案 2 :(得分:1)

我们有一个Web场,发现根本原因是并非所有服务器都在相同的Microsoft Windows补丁级别运行。一旦我们将它们全部带到相同的补丁级别,错误就会消失。

答案 3 :(得分:0)

您可能需要查看此内容:

http://jagbarcelo.blogspot.com/2009/08/solution-padding-invalid-cannot-be.html

请注意,我们遇到了类似的问题,并且在web.config中设置机器密钥部分的验证和解密属性似乎有所帮助,例如:

<machineKey validationKey='blah' decryptionKey='blah' validation='AES' decryption='AES'/>