Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

connectionString encryption

I'm trying to encrypt the connection strings in my web.config. I'm following the instructions from Walkthrough: Creating and Exporting an RSA Key Container. However, when I get to the part with the command:

aspnet_regiis -pe "connectionStrings" -app "/MyApplication" -prov "MyProvider"

it keeps complaining:

"The configuration for the virtual path '/MyApplication' and site 'Default Web Site' cannot be opened

Failed to map the path '/myapplication'
Failed!

I'm fairly sure I've followed the instructions correctly. I created the project named 'MyApplication' directly in the 'C:' root.

Any ideas? Perhaps I should be following a different set of instructions?

like image 274
BigJim Avatar asked Dec 20 '10 01:12

BigJim


People also ask

Should you encrypt connection strings?

It means that connection specific information such as database name, username, and password are stored as a clear text in a file. This is definitely a security concern for your Production servers. This is why the connection strings should be encrypted.

How do I encrypt a connection string in web config?

In order to encrypt the ConnectionString section in the Web. Config file, we will need to use the aspnet_regiis.exe tool. Action – It notifies the action to be performed. In order to perform Encryption, the parameter value is -pef.

How do I encrypt a SQL connection string?

To encrypt a connection from SQL Server Management Studio: On the Object Explorer toolbar, select Connect, and then select Database Engine. In the Connect to Server dialog box, complete the connection information, and then select Options. On the Connection Properties tab, select Encrypt connection.


2 Answers

Thanks for your answers. Turned out I needed to run the command prompt as "Administrator"

like image 102
BigJim Avatar answered Sep 28 '22 01:09

BigJim


Did you add the MyApplication folder as a virtual directory in IIS under the default web site? That seems to be what it's looking for, not a folder path...

According to this MSDN post, you can use -site to define the site to target. An excerpt from that site:

Use the –app option to identify the application for which the Web.config file will be encrypted and the -site option to identify which Web site the application is a part of. The Web site is identified using the site number from the Internet Information Services (IIS) metabase. You can retrieve the site number from the INSTANCE_META_PATH server variable in the ServerVariables collection. For example, when IIS is installed, a Web site named "Default Web Site" is created as site 1. In pages served from that site, the INSTANCE_META_PATH server variable returns "/LM/W3SVC/1". If you do not specify a -site option, site 1 is used.

like image 20
Brian Mains Avatar answered Sep 28 '22 02:09

Brian Mains