2个域之间的Cookie解密问题

时间:2010-10-22 12:04:09

标签: asp.net sharepoint iis

我正在开发一些aspnet C#3.5 webapp。我们在测试服务器上使用IIS7。

此Web应用程序通过Web服务与SharePoint 2007 3.0 SP2进行通信。我们在web.config(webapp和其中一个Sharepoint站点之一)中都有一个machineKey。这两个站点位于两个不同的服务器上。

此通讯工作正常。

我们还有一些自制的SSO:在webapp中使用点击链接然后在新窗口中打开SharePoint并且用户已经登录。 此SSO由两个应用程序(同名,同一域)中的“共享”cookie管理。

<authentication mode="Forms">
      <forms domain="crm.local" 
             enableCrossAppRedirects="true" 
             loginUrl="*** url to login page ***" 
             name=".CrmAuth" 
             protection="All" 
             slidingExpiration="true" timeout="200">
      </forms>

在SharePoint中,我们开发了一个RedirectModule,它从cookie中解密auth票证并记录用户。

HttpCookie authCookie = app.Request.Cookies[FormsAuthentication.FormsCookieName];

if (authCookie != null)
 {    
   FormsAuthenticationTicket authTicket = FormsAuthentication.Decrypt(authCookie.Value);

   FormsIdentity identity = new FormsIdentity(authTicket);
   GenericPrincipal principal = new GenericPrincipal(identity, null);
}

但是,突然之间,这个SSO已经崩溃了。当SharePoint尝试解密cookie时,会抛出异常:

[HttpException (0x80004005): unable to validate data]
   System.Web.Configuration.MachineKeySection.EncryptOrDecryptData(Boolean fEncrypt, Byte[] buf, Byte[] modifier, Int32 start, Int32 length, IVType ivType, Boolean useValidationSymAlgo, Boolean signData) +1008
   System.Web.Configuration.MachineKeySection.EncryptOrDecryptData(Boolean fEncrypt, Byte[] buf, Byte[] modifier, Int32 start, Int32 length, IVType ivType, Boolean useValidationSymAlgo) +91
   System.Web.Security.FormsAuthentication.Decrypt(String encryptedTicket) +246

两台服务器上都没有变化。可能是什么原因? 我该怎么做才能解决它?

1 个答案:

答案 0 :(得分:0)

这是由于本地网络上的某些反向代理服务器箱发生了变化......