<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>dotnet thoughts &#187; Connection string encryption</title>
	<atom:link href="http://www.dotnetthoughts.net/tag/connection-string-encryption/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dotnetthoughts.net</link>
	<description>a dotnet developer&#039;s technical blog</description>
	<lastBuildDate>Wed, 08 Feb 2012 03:18:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Encrypting and Decrypting Configuration Sections</title>
		<link>http://www.dotnetthoughts.net/2010/02/04/encrypting-and-decrypting-configuration-sections/</link>
		<comments>http://www.dotnetthoughts.net/2010/02/04/encrypting-and-decrypting-configuration-sections/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 09:27:26 +0000</pubDate>
		<dc:creator>Anuraj P</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[.Net 3.0 / 3.5]]></category>
		<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[Connection string encryption]]></category>

		<guid isPermaLink="false">http://www.dotnetthoughts.net/?p=746</guid>
		<description><![CDATA[Recently I got chance to work with security audit team for my web application, and one suggestion I got from them is to encrypt connection strings section in web.config. I thought it involves lot of coding changes, and I was &#8230; <a href="http://www.dotnetthoughts.net/2010/02/04/encrypting-and-decrypting-configuration-sections/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Recently I got chance to work with security audit team for my web application, and one suggestion I got from them is to encrypt connection strings section in web.config. I thought it involves lot of coding changes, and I was not aware of ASP.Net utility which will help to encrypt and decrypt the connection strings or appsettings sections of the web application. There is no extra coding required to use this feature. You can encrypt /decrypt the connection strings / appsettings using the ASPNET_REGIIS utility. You can find this utility in your Framework folder, normally in C:\Windows\Microsoft.NET\Framework\[Version]. Or you can invoke this from Visual Studio Command Prompt.</p>
<p><strong>Encrypt the connection string </strong></p>
<pre class="brush: bash; title: ; notranslate">
aspnet_regiis -pe ConnectionString  –app &quot;/docs&quot;
</pre>
<p>where –pe is the parameter used to encrypt the section. Connection string is the section, if you want to encrypt AppSettings, use appsettings instead of Connectionstrings. And the –app parameter is used to specify the application (it must be virtual path and need to start with “/”), if –app parameter is not specified it will encrypt the Root web.config. If the application is in File System, you need to specify –pef and Physical location as the parameter.</p>
<pre class="brush: bash; title: ; notranslate">
aspnet_regiis -pef ConnectionString  –app &quot;D:\MyWebApp&quot;
</pre>
<p><strong>Decrypt the connection string</strong></p>
<p>It is almost same as Encryption, only difference is instead of –pe use –pd. And in the case of –pef use –pdf.</p>
<pre class="brush: bash; title: ; notranslate">
aspnet_regiis -pd ConnectionString  –app &quot;/docs&quot;
</pre>
<p>and</p>
<pre class="brush: bash; title: ; notranslate">
aspnet_regiis -pdf ConnectionString  –app &quot;D:\MyWebApp&quot;
</pre>
<p>You can also specify the Provider for Encryption too. Use –prov parameter for providing custom provider (You can create your own provider, for this you need to inherit from ProtectedConfigurationProvider class). By default it will be RsaProtectedConfigurationProvider.<br />
Screenshots &#8211; Before and After encrypting the app settings.</p>
<div id="attachment_748" class="wp-caption alignnone" style="width: 482px"><a href="http://www.dotnetthoughts.net/wp-content/uploads/2010/02/before_enc.jpg"><img src="http://www.dotnetthoughts.net/wp-content/uploads/2010/02/before_enc.jpg" alt="Before Encryption" title="Before Encryption" width="472" height="55" class="size-full wp-image-748" /></a><p class="wp-caption-text">Before Encryption</p></div>
<div id="attachment_758" class="wp-caption alignnone" style="width: 481px"><a href="http://www.dotnetthoughts.net/wp-content/uploads/2010/02/after_enc1.jpg"><img src="http://www.dotnetthoughts.net/wp-content/uploads/2010/02/after_enc1.jpg" alt="After Encryption" title="After Encryption" width="471" height="460" class="size-full wp-image-758" /></a><p class="wp-caption-text">After Encryption</p></div>
<div class="betterrelated"><p><strong>Related content:</strong></p>
<ol><li> <a href="http://www.dotnetthoughts.net/2009/09/23/import-export-data-in-ms-excel-using-c/" title="Permanent link to Import / export data in MS Excel using C#">Import / export data in MS Excel using C#</a>  </li>
<li> <a href="http://www.dotnetthoughts.net/2010/06/29/implementing-asp-net-forms-authentication-with-active-directory-membership-provider/" title="Permanent link to Implementing ASP.Net Forms Authentication with Active Directory Membership Provider">Implementing ASP.Net Forms Authentication with Active Directory Membership Provider</a>  </li>
<li> <a href="http://www.dotnetthoughts.net/2009/07/30/implementing-windows-authentication-in-asp-net-on-iis-7/" title="Permanent link to Implementing Windows authentication in ASP.NET on IIS 7">Implementing Windows authentication in ASP.NET on IIS 7</a>  </li>
<li> <a href="http://www.dotnetthoughts.net/2011/11/18/how-to-create-a-rss-feed-using-asp-net/" title="Permanent link to How to create a RSS feed using ASP.Net">How to create a RSS feed using ASP.Net</a>  </li>
<li> <a href="http://www.dotnetthoughts.net/2009/04/27/using-multiple-active-result-sets-mars/" title="Permanent link to Using Multiple Active Result Sets (MARS)">Using Multiple Active Result Sets (MARS)</a>  </li>
</ol></div>]]></content:encoded>
			<wfw:commentRss>http://www.dotnetthoughts.net/2010/02/04/encrypting-and-decrypting-configuration-sections/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

