asp.net - 如何使用 aspnet_regiis 选择/强制执行 AES 加密来加密 web.config 值?

标签 asp.net encryption web-config aes aspnet-regiis.exe

我需要为 ASP.Net 4.0 项目加密部分 web.config,但我们需要使用 AES,默认值似乎是 Triple DES。我如何告诉它使用 AES 加密?

在命令提示符中,我执行以下命令:

aspnet_regiis -pc "NetFrameworkConfigurationKey" -exp
aspnet_regiis -pe "connectionStrings" -app "/<myapp>"

我想我通过选择适当的 CSP (-csp) 将加密方法设置为 AES,但我无法找到或弄清楚正确的名称。

加密的 web.config 中的一行是:

<EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#tripledes-cbc" />

最佳答案

使用 aspnet_regiis 的 -prov 参数选择提供程序。提供程序使用 configProtectedData 部分在 web/machine.config 中注册。为了注册 AES,您可以使用如下内容:

<configProtectedData>
    <providers>
        <add name="AesProvider"
            type="Microsoft.ApplicationHost.AesProtectedConfigurationProvider"
            description="Uses an AES session key to encrypt and decrypt"
            keyContainerName="iisConfigurationKey" cspProviderName=""
            useOAEP="false" useMachineContainer="true"
            sessionKey="aSessionKeyGoesHere" />
    </providers>
</configProtectedData>

在我的机器上,RSA和DPAPI是machine.config中预先配置的算法。

如果 AES 提供程序已注册,您应该能够使用以下方法加密配置部分:

aspnet_regiis -pe "connectionStrings" -app "/<myapp>" -prov "AesProvider"

关于asp.net - 如何使用 aspnet_regiis 选择/强制执行 AES 加密来加密 web.config 值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8776386/

相关文章:

ASP.NET AutoEventWireup和Inherits是什么意思?

python - NotImplementedError : Use module Crypto. Cipher.PKCS1_OAEP 而不是错误

用于 HTTPS 连接的 Powershell SSL TLS 密码套件

.net - WCF @ServiceHost 调试 ="true"但 web.config 编译 ="false"

ssl - URL Rewrite Force to https 除了一个域

asp.net - 启用代码优先 Entity Framework VS Web Express 2012

asp.net - 网站无法运行 服务器/应用程序中出现错误

c# - 在数据库中插入记录时连接必须有效且打开

java - 使用来自 github 的 AES-256-CBC 加密

Azure Web App HTTP/HTTPS 重写规则