Quantcast
Channel: Security
Viewing all articles
Browse latest Browse all 4737

Issue encrypting using ASPNET_REGIIS with a custom RSA Key Container

$
0
0

OS: Server 2008 R2 Enterprise

.NET Framework versions installed: 1.0.3705, 1.1.4322, 2.0.50727, 4.0.30319

I have been asked to encrypt connectionStrings and a few other sections of the web.config files on our web servers. My goal is to create a custom RSA Key Container, get it working successfully on one server, export it to an .XML file, and import/use to encrypt on other similar web servers. 

After doing a lot of reading, mostly from https://msdn.microsoft.com/en-us/library/2w117ede(v=vs.100).aspx it seems like a pretty basic process, but I keep getting an error I cannot defeat. Here's what I have done so far successfully:

1) Changed to the \WINDOWS\Microsoft.Net\Framework\v2.0.50727 directory and successfully ran aspnet_regiis -pc "MyKeys" -expto create the key pair and make it exportable.

2) Granted the 'Network Service' account read access to the key (from what I am reading/seeing, the ASP.Net service uses 'Network Service' as its logon so this should be the only account I need to grant this right to) aspnet_regiis -pa "MyKeys" "NT AUTHORITY\NETWORK SERVICE"

3) Confirmed I had a connectionStrings section already present in web.config, and then created a >configureProtectedData> section like shown below. NOTE that apparently older versions of the article left a space out of the 'Version=2.0.0.0' section, so those copying/pasting had a problem. I DID leave mine as shown below, as 2.0.0.0

4) I made sure the change didn't break anything in the config file, then went to encrypt the connectedString section using the following command (using -pef instead of -pe since I am calling out a file path and not an app/site) aspnet_regiis -pe"connectionStrings" E:\FilePath -prov "MyProvider"

5) I consistently get the following error: 'the given assembly name or codebase was invalid. <Exception from HRESULT: 0x80131047>'

I am brand new to this, for all I know there are logs I can reference that easily explain the problem. I can't seem to find them if that's the case.

For reference, I also tried this via the newest version of .NET/ASP I have installed (going thru the same steps above, just a different directory to run ASPNET. Pretty stuck, any help appreciated!

<configProtectedData><providers><add name="MyProvider"
              type="System.Configuration.RsaProtectedConfigurationProvider, System.Configuration, Version=2.0.0.0,
                    Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a,
                    processorArchitecture=MSIL"
              keyContainerName="MyKeys" 
              useMachineContainer="true" /></providers></configProtectedData>

Viewing all articles
Browse latest Browse all 4737

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>