Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem exporting RSA key -'key not valid for use in specified state'

I'm encrypting the web.config in our web sites using aspnet_regiis. However, I want the ability to export the encryption key so if we need to move from Machine A to Machine B, asp.net will be able to decrypt it.

When I run aspnetregiis -px "NetFrameworkConfigurationKey" c:\keys.xml -pri, I get the following : 'Key not valid for use in specified state'. I've seen all kinds of responses online but they don't seem to apply. It's not an invalid key because when I use aspnet_regiis to encrypt sections of the web.config, they encrypt fine.

Ideas?

like image 575
Bill Martin Avatar asked Sep 02 '25 17:09

Bill Martin


2 Answers

You need to specify the key set as exportable on creation, say Machine A is the machine it is created on

Run this command on Machine A:

aspnet_regiis -pc "NetFrameworkConfigurationKey" –exp

Then import the key on Machine B:

aspnet_regiis -pi "iListingKeys" "C:\New Folder\NetFrameworkConfigurationKey.xml"

More info: http://msdn.microsoft.com/library/yxw286t2.aspx

like image 77
ShaneC Avatar answered Sep 05 '25 15:09

ShaneC


Maybe you trying export private key that marked as non-exportable.

like image 33
Gorf Avatar answered Sep 05 '25 15:09

Gorf