2017-09-15 44 views
0

我必須加密我的web.config與section.sectioninformation.protectsection()和相同的web.config將運行3個服務器。加密web.config與protectsection()爲獨立的機器

是否有任何可能的方法來完成此任務。

+0

按照以下鏈接: https://www.codeproject.com/Tips/877258/How-to-Encrypt-Web-config-Using-aspnet-regiis-exe 您將不得不使用** aspnet_regiis.exe ** 。例如 'aspnet_regiis.exe -pef'命令(加密) 該命令對特定硬盤驅動器位置中的特定部分進行加密,以便例如對位於「C:\ inetpub \ wwwroot \ app」的站點中的「appSettings」部分進行加密\ WebConfigEncryption「運行: 'aspnet_regiis.exe -pef appSettings C:\ inetpub \ wwwroot \ app \ WebConfigEncryption' – Nirzar

回答

0

我從來沒有這樣做過編程,但使用aspnet_regiis.exe,將以下部分添加到web.config文件中。注:確保類型信息是正確的 - 查看machine.config。

<configProtectedData defaultProvider="myRsaProvider"> 
    <providers> 
     <add name="myRsaProvider" 
      type="System.Configuration.RsaProtectedConfigurationProvider, System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" 
      keyContainerName="myRsaKeys" 
      useMachineContainer="true" /> 
    </providers> 
</configProtectedData> 

在c。創建一個可導出機器級RSA密鑰容器

aspnet_regiis -pc "myRsaKeys"–exp 

授予權限密鑰容器

aspnet_regiis -pa "myRsaKeys" "yourDomain\yourUsername" 

加密的appSettings web.config中的部分:\ TEMP \使用定製RsaProtectedConfigurationProvider,myRsaProvider

aspnet_regiis -pef "appSettings" c:\temp\ -prov "myRsaProvider" 

導出RSA密鑰容器

aspnet_regiis -px "myRsaKeys" myRsaKeys.xml -pri 

導入您安裝web.config中的任何機器上的RSA密鑰容器。

aspnet_regiis -pi "myRsaKeys" myRsaKeys.xml