Visual Studio .NET - Encryption/decryption problem.

Asked By Byron King
08-Nov-07 02:21 PM

Hi.  I have an ASP.NET app that is built and deployed using MsBuild and a web deployment project.  A requirement for the project is to encrypt the connection string on the production server.  The connection string is not in web.config, but in a file called ConnectionStrings.config (catchy, eh?).

On the build server, I created a key with a command similar to the following:

[CODE]
aspnet_regiis -pc "KeyName" -exp -csp "Microsoft Strong Cryptographic Provider"
[/CODE]

I export the key to an XML file with this command:

[CODE]
aspnet_regiis -px "KeyName" "c:\KeyName.xml"
[/CODE]

I copy the XML file to the production server and then import it with the following command:

[CODE]
aspnet_regiis -pi "KeyName" "c:\KeyName.xml"
[/CODE]

Back on the build server, I encrypt  the connection strings with the following command:

[CODE]
aspnet_regiis -pef "connectionStrings" "c:\inetpub\wwwroot" -prov "ProviderName"
[/CODE]

When a deployment occurs, the ConnectionStrings.config file gets copied to the production server with all the other app code.  After the deployment is complete, any attempts to run the app or to manually decrypt the connection strings are met with an error message:

Parser Error Message: Failed to decrypt using provider 'ProviderName'. Error message from the provider: Bad Data.

I don't know what I'm missing, but I hope someone can help me.  Thanks!

export  export

08-Nov-07 05:07 PM
When you export the XML using the -px command, try using the -pri argument as well

i..e. aspnet_regiis -px "KeyName" "c:\KeyName.xml" -pri



Thanks  Thanks

08-Nov-07 05:12 PM
Mark,

Thanks for the reply.  The "-pri" should've been there.  As it turns out, I was using a similarly named, but incorrect KeyName.xml file for import.

Cheers,

Byron
Create New Account
help
Frequently asked Interview Questions in ADO.Net hi friends Any one send frequently asked Important questions in C# .Net, ADO .Net, Asp .Net and Sql Server. . . . . . . . tx in Advance. . . . . . Hi, Find this. . (B)What is an IL? (B is CTS? (B)What is a CLS (Common Language Specification)? (B)What is a Managed Code? (B)What is a Assembly? (A) What are the different types of Assembly? (B) What B) What is concept of Boxing and Unboxing ? (B) What is the difference between VB.NET and C#? (I) what is the difference between System exceptions and Application exceptions? (I)What is CODE Access security? (I)What is a satellite assembly? (A) How to prevent my .NET DLL
Interview Questions for .NET Framework This article is specially for the users those are in development or want to be a .net developer • To test a Web Service you must create a windows application or web application to consume this service? It is True / False? FALSE How many classes can a single.NET DLL contain? Answer1: As many Answer2: One or more What are good ADO.NET object(s) to replace the ADO Recordset object? The differences includes In ADO, the in memory representation of data is the recordset. In ADO.net, it is the dataset A recordset looks like a single table in ADO In contrast, a dataset is a collection of one or more tables in ADO.net ADO is designed primarily for connected access ADO net the disconnected access to the database is used In ADO you communicate with the database by making calls to an OLE DB provider. In ADO.NET you communicate with the database through a data adapter (an OleDbDataAdapter, SqlDataAdapter, OdbcDataAdapter, or OracleDataAdapter
authentication modes and its implementation in projects hi, i am doing a project in asp.net. . i want to use a authentication mode in this project.it is a educational based do some authentication in this project. How To: Use Forms Authentication with SQL Server in ASP.NET 2.0 patterns & practices Developer Center J.D. Meier, Alex Mackman, Blaine Wastell, Prashant Bansode, Andy Wigley, Kishore Gopalan Microsoft Corporation August 2005 Applies To • ASP.NET version 2.0 • SQL Server 2000 Summary This How To shows you how you can authentication, create the user store database, grant database access to your Web application account, configure ASP.NET membership settings, and set password complexity rules. Contents Objectives Overview Summary of Steps Step 1
ajax enabled site how do i get ajax enabled site in my .net 2.0. . .which setup i have to install for this. . i installed lots of setups but i dint get. . .anybody pls tell me. . .thanks in advance Hi Want to install ASP.NET AJAX and get started ? see this solution Installing ASP.NET AJAX Introduction This topic describes how to install Microsoft ASP.NET AJAX. It also describes how to install the optional ASP.NET 2.0 AJAX Futures CTP and optional ASP.NET AJAX Control Toolkit. ASP.NET
cannot display the webpage". plz help me! You can make use of inbuilt tool of visual studio publishing tool. The Publish Web Site tool precompiles the files in a Web site project you check the permission and authentication on your virtual directory ? yes! it showing exception Server Error in ' / Web' Application. Failed to access IIS metabase. Description: An unhandled exception occurred during the of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Web.Hosting.HostingEnvironmentException: Failed to access IIS metabase. The process account used to run ASP.NET must have read access to the IIS metabase (e.g. IIS: / / servername / W3SVC). For information on modifying metabase permissions, please see http: / / support.microsoft.com / ?kbid = 267904 . Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding