- Create a custom RSA key container (MyKeys can be replaced with any name).
- Open a CMD prompt
- Navigate to: c:\windows\microsoft.net\framework\v2.0
- Run the following command:
- aspnet_regiis.exe -pc "MyKeys" -exp
- Hit the ENTER key
- Find out what the identity of your ASP.NET application is running as.
- Open Notepad
- Paste in the following: <%@ Page Language="C#" %>
- Save the file as "identity.aspx" somewhere within your website where you can access from a browser
- Access this identity.aspx file from a browser. Make note of the account it displays to you
- Grant the identity access to the RSA key container (created in Step 1).
- Open a CMD prompt (if not already opened)
- Navigate to: c:\windows\microsoft.net\framework\v2.0
- Run the following command:
- aspnet_regiis.exe -pa "MyKeys" "NameOfASP.NETaccountReturnedAbove"
- Hit the ENTER key
- Specify an instance of a Protected Configuration provider in the web.config.
- Open your web.config in Notepad or some other editor.
- Make sure you have a <connectionStrings> section in your <configuration> section.
- Add a <configProtectedData> section. "MyProvider" can be replaced with any name.
- Example:
<%
Response.Write(System.Security.Principal.WindowsIdentity.GetCurrent().Name);
%>
- Encrypt the actual web.config.
- Open a CMD prompt (if not already opened)
- Navigate to: c:\windows\microsoft.net\framework\v2.0
- Run the following command. "MyApplication" should be replaced with your actual .NET application name:
- aspnet_regiis.exe -pe "connectionStrings" -app "/MyApplication" -prov "MyProvider"
- Or if using a UNC path:
- aspnet_regiis.exe -pe "connectionStrings" "\\path\path\to\.net\directory -prov "MyProvider"
<configuration>
<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>
<connectionStrings>
<add name="SqlServices" connectionString="Data Source=localhost;Integrated Security=SSPI;Initial Catalog=Northwind;" />
</connectionStrings>
</configuration>
No comments:
Post a Comment