简体   繁体   中英

encrypt web.config with protectsection() for independent machine

I have to encrypt my web.config with section.sectioninformation.protectsection() and same web.config will run over 3 servers.

Is There any Possible way to accomplish this task.

I've never done this programmatically but using aspnet_regiis.exe, add the following section to the web.config file. NB Make sure the type information is correct - look at 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>

Create an exportable machine-level RSA key container

aspnet_regiis -pc "myRsaKeys"–exp 

Grant permissions to the key container

aspnet_regiis -pa "myRsaKeys" "yourDomain\yourUsername"

Encrypt appSettings section of web.config in c:\\temp\\ using the custom RsaProtectedConfigurationProvider, myRsaProvider

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

Export the RSA key container

aspnet_regiis -px "myRsaKeys" myRsaKeys.xml -pri

Import the RSA key container on any machine where you install the web.config.

aspnet_regiis -pi "myRsaKeys" myRsaKeys.xml

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM