Archive for February, 2012

Encrypting and Decrypting Configuration Sections

How To_ Encrypt Configuration Sections in ASP.NET 2

Encrypting Configuration Sections

1. Create a new RSA Key which is exportable (for web farm deployment or backup purpose)

aspnet_regiis -pc “CustomKeys” -exp

2. Add and configure a custom protected configuration provider. To do this, add the following <configProtectedData> section to the Web.config file. Note that the key container name is set to “CustomKeys”, which is the name of the key container created previously.

<configProtectedData>
  <providers>
  <add keyContainerName="CustomKeys" 
           useMachineContainer="true"
           description="Uses RsaCryptoServiceProvider to encrypt and decrypt"
           name="CustomProvider"       type="System.Configuration.RsaProtectedConfigurationProvider,System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
  </providers>
</configProtectedData>

3. Encrypt the connection strings:

aspnet_regiis -pe “connectionStrings” -app “/WebFarmRSA” -prov “CustomProvider”

4. Grant Service Account access to the key

aspnet_regiis -pa “CustomKeys” “NT Authority\Network Service”

5. Export the key

aspnet_regiis -px “CustomKeys” “C:\CustomKeys.xml” -pri

Restore to Another Server

6. Import the key

aspnet_regiis -pi “CustomKeys” “C:\CustomKeys.xml”

7. Grant Service Account access to the key

aspnet_regiis -pa “CustomKeys” “NT Authority\Network Service”

Decrypting Configuration Sections

8. Decrypt the section

aspnet_regiis -pd "connectionStrings" -app "/SampleApplication"

Note: the tools assuming the “Default Web Sites” exists and work for the related path of the default web sites. The Default Web Sites is for reference purpose, no need to enable it.

,

No Comments

Team Foundation Build + Web Deployment + Web Deploy + VS2010

Nice article: s Tangent_ Team Build + Web Deployment + Web Deploy + VS 2010 = Goodness

Ref: http://vishaljoshi.blogspot.com/2010/11/team-build-web-deployment-web-deploy-vs.html

,

No Comments

Building Silverlight 4 apps with Team Build 2010

You need to install the Siverlight SDK on your build servers!... and run the 32-bit Build Tools on a 64-bit machine.

Error messages:

The imported project “C:\Program Files (x86)\MSBuild\Microsoft\Silverlight\v4.0\Microsoft.Silverlight.CSharp.targets” was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

or

C:\Program Files (x86)\MSBuild\Microsoft\Silverlight\v4.0\Microsoft.Silverlight.Common.targets (104): The Silverlight 4 SDK is not installed.

Required Steps:

  1. Install Silverlight 4 SDK on Build Agents.
  2. In the Build Definition, change the MSBuild Platform from Auto to x86, as describedhere.

 

,

No Comments