2013-03-12 221 views
17

未能使用提供者'RsaProtectedCo nfigurationProvider'加密節'connectionStrings'。來自提供者的錯誤消息:對象已經存在。未能使用提供者'RsaProtectedConfigurationProvider加密節'connectionStrings'

我跟着指南中http://msdn.microsoft.com/en-us/library/2w117ede.aspx但在步驟3中要授予ASP.NET身份訪問RSA密鑰容器,它說,我的身份是我的工作組\用戶名,我沒有冒充我的web.config文件雖然

我使用asp_regiis使用我的機器上使用Visual Studio調試,然後加密的web.config,然後纔出現了這個錯誤

+1

可能Duplicate: [來自其他帖子](http://stackoverflow.com/questions/8344373/encrypting-web-config-using-aspnet-regiis)其實運行CMD作爲管理員解決了我的問題呢! – Yash 2013-05-08 20:43:22

+3

以管理員模式啓動命令提示符,然後繼續。應該解決這個問題。 – Sam 2014-05-07 21:26:26

回答

44

對於使用RsaProtectedConfigurationProvider您需要啓動命令提示符或Visual Studio 作爲管理員

對於DataProtectionConfigurationProvider它不需要在管理權限下運行。

+2

我的經驗是,您不能僅以管理帳戶登錄並啓動通用命令提示符。當我這樣做時,aspnet_regiis失敗。我必須在cmd.exe或Visual Studio命令提示符下實際執行「以管理員身份運行」。然後aspnet_regiis按預期工作。 – kermit 2015-10-18 23:17:44

+0

是的,您需要提升管理員權限,雖然這將取決於您的系統用戶設置(因爲在某些情況下,登錄的管理員不需要提升應用程序)以便對計算機進行這些更改。 – markthewizard1234 2016-08-16 10:02:20

+0

這讓我一直都在。 – rageit 2016-08-30 20:12:19

0

您可以使用RsaProtectedConfigurationProvider創建您自己的提供程序,無需管理員權限即可加密您的web.xml。

  1. 創建密鑰存儲區:

    ASPNET_REGIIS -pc 「MyKeyStore」 -exp

  2. 授予讀取任何用戶訪問:

    aspnet_regiss -pa 「MyKeyStore」「域/用戶「

  3. 將供應商部分放到您的web.config中

    <configProtectedData> 
    <providers> 
        <add name="MyRSAProvider" type="System.Configuration.RsaProtectedConfigurationProvider,System.Configuration, Version=2.0.0.0,&#xD;&#xA; Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a,&#xD;&#xA; processorArchitecture=MSIL"keyContainerName="MyKeyStore"useMachineContainer="true" /> 
    </providers> 
    </configProtectedData> 
    
  4. 加密你的配置部分:

    ASPNET_REGIIS -pef 「configSection」 「C:\ pathToWebConf」 -prov 「MyRSAProvider」

來源:

Create RSA key container and provider

Encrypt configuration

相關問題