加密的连接字符串无法解密

Encrypted connection string can not be decrypted

我即将发布我的应用程序,但我希望对我的连接字符串进行加密。

aspnet_regiis -pef "sectionName of web.config" "path"

上面的命令完成了工作,我将我的应用程序发布到服务器,然后 运行 在服务器机器上执行以下命令:

aspnet_regiis -pa "NetFrameworkConfigurationKey" "identityOfMyAppPool"

但是当我尝试浏览我的应用程序时,出现以下错误:

Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error

Message: Failed to decrypt using provider 'RsaProtectedConfigurationProvider'. Error message from the provider: The data to be decrypted exceeds the maximum for this modulus of 128 bytes.

我该如何解决?

提前致谢,

试试

aspnet_regiis -pe "NetFrameworkConfigurationKey" "identityOfMyAppPool"

而不是

aspnet_regiis-pa"NetFrameworkConfigurationKey""identityOfMyAppPool"

根据 aspnet_regiis /help 或 aspnet_regiis /?

-pe

加密配置部分。可选参数: [-prov provider] 使用此提供程序进行加密。 [-app virtual-path] 在此虚拟路径中加密。虚拟的 路径必须以正斜杠开头。如果是'/',那么它 指的是网站的根目录。如果未指定 -app, 根 web.config 将被加密。 [-site site-name-or-ID] 虚拟路径的站点 在 -app 中指定。如果不指定,默认网站 将会被使用。 [-location 子路径] 位置子路径。 [-pkm] Encrypt/decrypt machine.config 而不是 web.config.

-pa

添加帐户对容器的访问权限。阿古 [-pku] 用户容器而不是机器容器 [-csp 提供者] 要使用的 Csp 提供者。 [-full] 添加完全访问权限(默认为读取访问权限)。

返回此错误消息的一个实例是使用 2048 位 RSA 密钥加密 web.config,并尝试使用 1024 位 RSA 密钥解密。仔细检查以确保两台机器上的密钥相同(您只需要加密机器上密钥的 public 部分)。

默认情况下,NetFrameworkConfigurationKey 在每台机器上都是不同的(并且不可导出?)。要从另一台机器部署加密的 web.config,您需要从目标机器导出 public 密钥并使用它来加密(或者按照所有教程创建自己的密钥并将其放在两台机器上...).