2012-07-05 52 views
4

我有在同一服务器上运行两个.NET Web应用程序之间FormsAuthentication - 定点(在https://sentinel.mydomain.com/托管)和fortknox(在http://www.mydomain.com/fortknox“无法验证数据”使用不同的Web应用程序

是哨兵一个认证'门户'。 FortKnox是一个'概念验证'应用程序,它使用表单身份验证,但将loginUrl设置为https://sentinel.mydomain.com/login(以及特殊的Application_EndRequest处理程序以限定ReturnUrl)。 Sentinel使用MVC 4和Razor在.NET 4.0中编写; FortKnox是使用.NET 2.0的ASP.NET MVC 2。

我正在使用ASP.NET FormsAuthentication并将cookie域设置为.mydomain.com,以便将由sentinel.mydomain.com设置的Cookie发送请求至www.mydomain.com,反之亦然。 Cookie部分工作正常 - 两个应用程序都获得相同的.ASPXAUTH加密表单票证。

的问题是,在我们的生产服务器,fortknox不能解密定点创建的cookie - 即使他们有相同的机键。即使两个应用程序都在同一个物理盒子上运行,它也不起作用。

用户点击fortknox,他们重定向到定点,他们登录的Cookie设置,他们重定向回fortknox,然后我得到“无法验证数据”:

Exception: Unable to validate data. 
    at System.Web.Configuration.MachineKeySection.EncryptOrDecryptData(Boolean fEncrypt, Byte[] buf, Byte[] modifier, Int32 start, Int32 length, IVType ivType, Boolean useValidationSymAlgo, Boolean signData) 
    at System.Web.Configuration.MachineKeySection.EncryptOrDecryptData(Boolean fEncrypt, Byte[] buf, Byte[] modifier, Int32 start, Int32 length, IVType ivType, Boolean useValidationSymAlgo) 
    at System.Web.Security.FormsAuthentication.Decrypt(String encryptedTicket) 
    at FortKnox.Web.MvcApplication.Application_BeginRequest() 

本机键是相同的 - 我已经尽可能包括该区块的每个页面的加价(讨厌!)代码:

try { 
    var cookie = Request.Cookies[".ASPXAUTH"].Value; 
    Response.Write("Cookie: " + cookie + Environment.NewLine); 
    var ticket = FormsAuthentication.Decrypt(cookie); 
    Response.Write("Ticket name: " + ticket.Name + Environment.NewLine); 
} catch (Exception x) { 
    Response.Write("Exception: " + x.Message + Environment.NewLine); 
    Response.Write(x.StackTrace); 
} 
Response.Write("<hr /></pre>"); 
var machineConfigMachineKey = (MachineKeySection)WebConfigurationManager.OpenMachineConfiguration().SectionGroups["system.web"].Sections["machineKey"]; 
var webConfigMachineKey = (MachineKeySection)WebConfigurationManager.OpenWebConfiguration("").SectionGroups["system.web"].Sections["machineKey"]; 
Response.Write("<pre>"); 
Response.Write("<b>machine.config decrypt: </b>" + machineConfigMachineKey.DecryptionKey + "<br />"); 
Response.Write("<b>web.config decrypt:  </b>" + webConfigMachineKey.DecryptionKey + "<br />"); 
Response.Write("<br />"); 
Response.Write("<b>machine.config validate: </b>" + machineConfigMachineKey.ValidationKey + "<br />"); 
Response.Write("<b>web.config validate:  </b>" + webConfigMachineKey.ValidationKey + "<br />"); 
Response.Write("</pre>"); 
Response.Write("<hr />"); 

,并验证了在运行时所使用的机器密钥一模一样。

特别令人沮丧的是,这一直在我们的开发和登台服务器上工作,并且只在生产中失败。服务器之间唯一的区别在于生产环境中经常安装Windows更新,而我们的开发/升级框可能会缺少一些更新;他们在其他方面是相同的(从相同的图像克隆,并使用相同的安装脚本创建)

所以...同样的服务器;相同的机器密钥。 ASP.NET 4设置了FormsAuthentication cookie。 ASP.NET 2应用程序无法解密它。仅在某些服务器上发生错误;在别人身上,它正在工作。在这一点上,我完全卡住了......有什么想法?

编辑:Live服务器已被带到最新的补丁级别。我曾尝试申请

<add key="aspnet:UseLegacyEncryption" value="true" /> 

既是真假,双方在登录应用程序和应用程序fortknox。仍然没有运气...

+0

我有同样的问题,并且已经尝试了3个按键,但没有成功,它采用2.0和1.1,目前之间的合作与2.0和1.1的工作,但不能与4.0 – 2013-11-07 13:17:35

回答

1

你尝试下列所有键? http://support.microsoft.com/kb/2425938

<add key="aspnet:UseLegacyEncryption" value="true" /> 
<add key="aspnet:UseLegacyMachineKeyEncryption" value="true" /> 
<add key="aspnet:ScriptResourceAllowNonJsFiles" value="true" /> 
相关问题