机器密钥更改后 ASPX 匿名 Cookie 被破坏

发布于 2024-11-08 03:31:07 字数 416 浏览 4 评论 0原文

我的公司最近遇到了流量高峰,因此我们尝试启动额外的 EC2 实例来处理负载。不幸的是,这导致用户出现 cookie 问题(即,即使您提供了凭据,网站仍不断要求登录)。我们认为这是因为我们忽略了在 Web.config 文件中设置计算机密钥(每台负载平衡计算机上的 Web.config 文件在其他方面都是相同的)。

我们现在不想在 Web.config 中设置新的机器密钥值,因为这会注销所有匿名用户,他们可能已经将商品添加到购物车等。但是我们还想支持缩放。

那么,问题是:

  1. 我们的假设是否正确,即机器密钥是用户需要新 cookie 的罪魁祸首?
  2. 有没有什么方法可以确定正在使用的当前或默认机器密钥,以便我们可以将其复制到其他负载平衡服务器?
  3. 失败2,有没有办法设置新的机器密钥而不丢失我们的匿名用户的数据?

My company recently got hit with a traffic spike, so we tried to fire up additional EC2 instances to handle the load. Unfortunately, this caused users problems with cookies (i.e. site kept asking for login even after you supplied credentials). We think this is because we had neglected to set the Machine Key in our Web.config file (the Web.config files on each load balanced machine are otherwise identical).

We're now in the position where we don't want to set a new Machine Key value in Web.config, because that will log out all of our anonymous users, who may have already added items to their cart, etc. But we also want to support scaling.

So, questions:

  1. Is our assumption correct that the Machine Key is the culprit for user's needing new cookies?
  2. Is there any way of determining the current or default Machine Key that is being used so that we can copy it to the other load balanced servers?
  3. Failing 2, is there a way to set a new Machine Key without losing our anonymous user's data?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

↘紸啶 2024-11-15 03:31:07

您没有提到您正在使用什么身份验证方法,但如果是表单身份验证,那么是的 - 您的计算机密钥需要在场中的所有服务器之间匹配。您还应该确保所有计算机都打了同样的补丁,因为有多个补丁(特别是 ASP.NET 安全漏洞更新)会更新加密位。

如果您使用默认配置,则机器密钥可能会设置为“自动生成”。据我所知,没有简单的方法可以揭示自动生成的机器密钥的设置。但是,由于您可以访问现有服务器,因此您可能可以通过一些反射代码找到它,如下所示:

http: //aspnetresources.com/blog/how_to_read_auto_ generated_machinekey

You didn't mention what method of authentiation you are using, but if it's forms authentication, then yes - your machine keys need to match across all servers in your farm. You should also make sure that all of your machines are equally patched as there have been several patches (specifically the asp.net security vulnerabilty updates) that update the cryptography bits.

If you're using the default configuration, the machine key is likey set to AutoGenerate. As far as I know, there is no simple way to reveal what the autogenerated machine key is set to. However, since you have access to your exising server, you can probably find it via a little reflection code as illustrated here:

http://aspnetresources.com/blog/how_to_read_auto_generated_machinekey

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文