3

我需要为我们的 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" />
4

1 回答 1

1

使用 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"
于 2012-01-08T11:33:13.190 回答