Last active
April 12, 2018 19:49
-
-
Save garfbradaz/dde40662318ac94627275037e020c479 to your computer and use it in GitHub Desktop.
Encrypt config file using RSA and export keys
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GOTO EndComment | |
This batch file will encrypt a app.config file using aspnet_regiis. You can use other windows directories to run | |
the application depending on which version you have installed. | |
The batch file assumed you have app.config file incuded in the direcorty you are running the batch file AND has been amended to | |
include the appropriate provided. | |
See this article on details on how to setup the config etc and what each command does | |
https://mywebanecdotes.com/2016/09/17/encrypting-credentials-in-app-config-for-multiple-machines/ | |
The article describes on how to import the keys to different machnes as well. | |
:EndComment | |
cd %~dp0 | |
copy app.saved.config web.config | |
%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -pc MyCustomKeys -exp | |
%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -pa MyCustomKeys "NT AUTHORITY\NETWORK SERVICE" | |
%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -pef CustomConfig . -prov MyEncryptionProvider | |
%windir%\Microsoft.NET\Framework64\v4.0.30319\v4.0.30319\aspnet_regiis.exe -px CustomKeys keys.xml -pri | |
pause |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment