我们(实际上是我们的 IT 合作伙伴)最近为我们拥有的一个网站农场更改了一些 DNS,以便两个生产服务器在它们之间进行循环 DNS 切换。在此切换之前,我们实际上并没有遇到 WebResource.axd
文件的问题。自从切换以来,当我们点击实时公共 URL 时,我们会收到一个错误:
加密异常
填充无效且无法删除。
当我们访问特定服务器本身时,它们加载得很好。我研究了这个问题,看来由于它们在两台服务器之间共享资产,我们需要在每台服务器的 web.config
中拥有一致的 machineKey
,以便它们两者之间可以一致地加密和解密。我的问题是:
- 我可以通过服务器上的工具生成
machineKey
,还是需要编写代码来执行此操作?
- 我是否只需将
machineKey
添加到每台服务器上的 web.config
中,还是您认为我需要执行其他操作才能使两台服务器协同工作? (两个 web.config
目前都没有 machineKey
)
We (our IT partner really) recently changed some DNS for a web farmed site we have, so that the two production server have round-robin DNS switching between them. Prior to this switch we didn't really have problems with WebResource.axd
files. Since the switch, when we hit the live public URL, we get an error:
CryptographicException
Padding is invalid and cannot be removed.
When we hit the specific servers themselves, they load fine. I've researched the issue and it seems since they're sharing assets between two servers, we need to have a consistent machineKey
in the web.config
for each server so they can encrypt and decrypt consistently between the two. My questions are:
- Can I generate a
machineKey
via a tool on the server, or do I need to write code to do this?
- Do I just need to add the
machineKey
to the web.config
on each server or do you think I'll need to do anything else to make the two server work together? (Both web.config
's currently do not have a machineKey
)
发布评论
评论(3)
这应该回答:
如何:在 ASP.NET 2.0 中配置 MachineKey - Web Farm部署注意事项
简而言之,要设置机器密钥,请参阅以下链接:
设置机器密钥 - Orchard 文档。
并将以下行添加到
system.web
标记下的所有webservers
中的web.config
文件(如果不存在)。请确保您有机器密钥和
web.config
文件的永久备份This should answer:
How To: Configure MachineKey in ASP.NET 2.0 - Web Farm Deployment Considerations
In short, to set up the machine key refer the following link:
Setting Up a Machine Key - Orchard Documentation.
and add the following line to the
web.config
file in all thewebservers
undersystem.web
tag if it does not exist.Please make sure that you have a permanent backup of the machine keys and
web.config
file如果您使用的是 IIS 7.5 或更高版本,您可以从 IIS 生成计算机密钥并将其直接保存到 Web 场中的 web.config,然后只需将新的 web.config 复制到每个服务器即可。
web.config
文件。web.config
文件中。完整详细信息可以查看@ 生成 MachineKey 的最简单方法 - 提示和技巧:ASP.NET、IIS 和 .NET 开发...
If you are using IIS 7.5 or later you can generate the machine key from IIS and save it directly to your web.config, within the web farm you then just copy the new web.config to each server.
web.config
file of your application.web.config
file.Full Details can be seen @ Easiest way to generate MachineKey – Tips and tricks: ASP.NET, IIS and .NET development…
确保学习 padding oracle asp .net 漏洞 刚刚发生(您应用了补丁,对吧?...)并使用 用于加密机器密钥和任何其他敏感配置的受保护部分。
另一种选择是将其设置在计算机级别的 web.config 中,因此它甚至不在网站文件夹中。
要生成它,就像大卫回答中的链接文章一样。
Make sure to learn from the padding oracle asp.net vulnerability that just happened (you applied the patch, right? ...) and use protected sections to encrypt the machine key and any other sensitive configuration.
An alternative option is to set it in the machine level web.config, so its not even in the web site folder.
To generate it do it just like the linked article in David's answer.