gpt4 book ai didi

forms-authentication - "Unable to validate data"在不同的 Web 应用程序之间使用 FormsAuthentication

转载 作者:行者123 更新时间:2023-12-04 08:23:36 30 4
gpt4 key购买 nike

我在同一台服务器上运行了两个 .NET Web 应用程序 - 哨兵 (托管在 https://sentinel.mydomain.com/ )和 福特诺克斯 (在 http://www.mydomain.com/fortknox)

Sentinel 是一个身份验证“门户”。 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 加密表单票证。

问题是,在我们的生产服务器上,福特诺克斯 无法解密由 创建的 cookie哨兵 - 即使他们有相同的机器 key 。即使两个应用程序都在同一个物理盒子上运行,它也不起作用。

用户点击 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 />");

并验证运行时使用的机器 key 完全相同。

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

所以...相同的服务器;相同的机器 key 。 ASP.NET 4 设置 FormsAuthentication cookie。 ASP.NET 2 应用程序无法解密它。错误只发生在某些服务器上;在其他人身上,它正在起作用。在这一点上,我完全被困住了……有什么想法吗?

编辑 :实时服务器已升级到最新补丁级别。我试过申请
<add key="aspnet:UseLegacyEncryption" value="true" />

对于登录应用程序和 fortknox 应用程序,都是 true 和 false。还是没有运气...

最佳答案

它可能与旧的 2010 填充 oracle 安全补丁有关 - http://weblogs.asp.net/scottgu/archive/2010/09/28/asp-net-security-update-now-available.aspx ?尝试设置



强制打补丁的服务器像打补丁前一样运行?

(或者,你知道......修补你的服务器。你的选择。)

关于forms-authentication - "Unable to validate data"在不同的 Web 应用程序之间使用 FormsAuthentication,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11353299/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com