如何加密web.config中的连接字符串 [英] How to encrypt web.config connection string

查看:93
本文介绍了如何加密web.config中的连接字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图连接字符串中我的web.config进行加密。我已接着微软的准则,但它不工作。 http://msdn.microsoft.com/en-us/library/ff650304 #的.aspx paght000006_step3

I am trying to encrypt connection string in my web.config. I have followed the guidelines by microsoft, but it doesn't work. http://msdn.microsoft.com/en-us/library/ff650304.aspx#paght000006_step3

我经过加密配置部分成功了!在命令提示符。我删除了我的web.config是connectionStrings部分,并保持新增加的是connectionStrings与加密的数据。

After I got "encrypting configuration sections succeeded!" in command prompt. I deleted "connectionStrings" section from my web.config and kept the newly added "connectionStrings" with encrypted data.

我有实体框架的两个MSSQL数据库连接字符串,但我正在逐渐说:在运行时编译错误的指定的命名连接或者未在配置中发现,不打算与EntityClient提供者使用,或无效。

I had two MSSQL database connection strings for Entity Framework, but I am getting an error on runtime compile saying "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中显示错误说的无法使用提供商RSAProtectedConfigurationProvider ....的RSA密钥容器不能打开解密。

When you open up the model edmx file, and update model from database. Visual Studio displays error saying "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>

--------解决,下面回答。 ------

-------- solved, answer below. ------

推荐答案

当你运行ASPNET命令,加密的数据应取代是connectionStrings,如果没有,那么它失败了。为aspnet_regiis -pe是connectionStrings-app/-location子文件夹上门2

When you run aspnet commands, the encrypted data should replace the "connectionStrings", if it doesn't, then it failed. aspnet_regiis -pe "connectionStrings" -app "/" -location "subfolder" -site "2"

我跑了命令,但事实证明,我不需要-location那是不正确的。

I ran that command, but it turns out I don't need -location and that was incorrect.

我应该知道,当密码值XML领域是如此之小。

I should have known, when the cipher Value XML field was so small.

然而,这两个命令做的伎俩...

However, these two commands do the trick...

为aspnet_regiis -pe是connectionStrings-app/上门2

aspnet_regiis -pe "connectionStrings" -app "/" -site "2"

为aspnet_regiis -paNetFrameworkConfigurationKeyIIS APPPOOL \\ MyApp的

aspnet_regiis -pa "NetFrameworkConfigurationKey" "IIS APPPOOL\MyApp"

这篇关于如何加密web.config中的连接字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆