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
Check out this article: https://msdn.microsoft.com/en-us/library/ms998283.aspx
Command:
aspnet_regiis.exe -pef "connectionStrings" C:\Projects\MachineRSA
Sources:
https://stackoverflow.com/a/976117/3850405 https://stackoverflow.com/a/5717845/3850405 How to encrypt web.config section AND deploy to multiple servers with Amazon Elastic Beanstalk
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.