将machineKey添加到machine.config

问题描述 投票:18回答:4

我想将machineKey添加到我的machine.config中,因为我正在使用Web场方案中的web.config连接字符串的编程加密。

我的问题是,我在哪里将machineKey放在machine.config文件中?我已经没有可以替换的了,我怀疑它是自动生成的,所以应该放在哪里?

asp.net .net encryption web-config machine.config
4个回答
26
投票

把它放在<system.web>下面

如果您需要生成密钥,我想使用此网站上的工具:Machine Key Generator

更新:以上链接似乎已经死了,here is another site to generate keys


10
投票

<system.web>内:

<system.web>
    <machineKey 
        validationKey="....." 
        decryptionKey="....." 
    />

至少在我的文件的底部。我不认为system.web中元素的顺序很重要,只要它是system.web元素正下方的顶层。


2
投票

从站点获取密钥可能存在安全风险。

有一个简单的方法,只需使用您的IIS控制台

type inetMgr in Start

IIS控制台打开。单击计算机密钥

Computer Keys

下一步是设置您的密钥。选择适当的,取消标记框以手动生成密钥,最后单击生成密钥。

Screen where generate your keys

最后,进入你的Web.Config以及设置标签。

Setting the keys in web.config


1
投票
© www.soinside.com 2019 - 2024. All rights reserved.