search
Japanese Chinese Nederlands Espanol Italiano Deutsch Francais Twitter Rss Feeds
MicrosoftArticlesForumsFAQs
C# .NET
VB.NET
Visual Studio .NET
ADO.NET
Xml / Xslt
VB 6.0
.NET CF
GDI+
LINQ
Deployment
Security
FoxPro
Silverlight / WPF
Entity Framework
RIA Services

Web ProgrammingArticlesForumsFAQs
JavaScript
ASP
ASP.NET
Web Services

Non-MicrosoftArticlesForumsFAQs
NHibernate
Perl
PHP
Ruby
Java
Linux / Unix
Apple
Open Source

DatabasesArticlesForumsFAQs
SQL Server
Access
Oracle
MySQL
Other Databases

OfficeArticlesForumsFAQs
Excel
Word
Powerpoint
Outlook
Publisher
Money

Operating SystemsArticlesForumsFAQs
Windows 7
Windows Server
Windows Vista
Windows XP
Windows Update
MAC
Linux / UNIX

Server PlatformsArticlesForumsFAQs
BizTalk
Site Server
Exhange Server
IIS

Graphic DesignArticlesForumsFAQs
Macromedia Flash
Adobe PhotoShop
Expression Blend
Expression Design
Expression Web

OtherArticlesForumsFAQs
Subversion / CVS
Ask Dr. Dotnetsky
Active Directory
Networking
Uninstall Virus
Job Openings
Product Reviews
Search Engines
Resumes

 

View Other Visual Studio .NET Posts   Ask New Question 
Encryption/decryption problem.
Byron King posted at Thursday, November 08, 2007 2: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
mark macumber replied to Byron King at Thursday, November 08, 2007 5: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
Byron King replied to mark macumber at Thursday, November 08, 2007 5: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