我正在尝试加密web.config中的连接字符串 . 我遵循微软的指导方针,但它不起作用 . http://msdn.microsoft.com/en-us/library/ff650304.aspx#paght000006_step3
我得到“加密配置部分成功!”在命令提示符下 . 我从web.config中删除了“connectionStrings”部分,并将新添加的“connectionStrings”保存为加密数据 .
我有两个用于Entity Framework的MSSQL数据库连接字符串,但我在运行时编译时收到错误“ The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid. ”
当您打开模型edmx文件,并从数据库更新模型时 . Visual Studio显示错误“ Failed to decrypt using provider RSAProtectedConfigurationProvider....The RSA key container could not be opened."
<connectionStrings configProtectionProvider="RsaProtectedConfigurationProvider">
<EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element"
xmlns="http://www.w3.org/2001/04/xmlenc#">
<EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#tripledes-cbc" />
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<EncryptedKey xmlns="http://www.w3.org/2001/04/xmlenc#">
<EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5" />
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<KeyName>Rsa Key</KeyName>
</KeyInfo>
<CipherData>
<CipherValue>..........</CipherValue>
</CipherData>
</EncryptedKey>
</KeyInfo>
<CipherData>
<CipherValue>........</CipherValue>
</CipherData>
</EncryptedData>
</connectionStrings>
--------解决了,回答如下 . ------
3 回答
在发布项目的服务器上运行此代码
in this link : http://www.codeproject.com/Tips/304638/Encrypt-or-Decrypt-Connection-Strings-in-web-confi
看起来创建密钥的帐户与运行应用程序的帐户不同 . 您是否确保相应的帐户可以访问密钥存储区?从那篇文章中你发送了......
此外,these simple commands seemed to work用于EF / Linq-to-Entities
当您运行aspnet命令时,加密数据应该替换“connectionStrings”,如果没有,则失败 . aspnet_regiis -pe“connectionStrings”-app“/”-location“subfolder”-site“2”
我运行了那个命令,但事实证明我不需要-location,这是不正确的 .
我应该知道,当密码值XML字段如此之小时 .
但是,这两个命令可以解决问题......
aspnet_regiis -pe“connectionStrings”-app“/”-site“2”
aspnet_regiis -pa“NetFrameworkConfigurationKey”“IIS APPPOOL \ MyApp”