Problem with RSA key export -'key is not valid for use in the specified state '

I encrypt web.config on our sites using aspnet_regiis. However, I want the ability to export the encryption key, so if we need to switch 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: "The key is not valid for use in the specified state." I have seen all kinds of answers on the Internet, but they don't seem to apply. This is not an invalid key, because when I use aspnet_regiis to encrypt the web.config sections, they encrypt the penalty.

Ideas?

+3
source share
2 answers

You need to specify the key set as exported when you create, say, machine A is the machine that it 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"

Additional information: http://msdn.microsoft.com/library/yxw286t2.aspx

+3
source

Perhaps you are trying to export a private key that is marked as non-exportable.

+2
source

Source: https://habr.com/ru/post/1741470/


All Articles