简体   繁体   中英

C# RSA Decryption Issue

I tried encrypting connection string on my machine A . It was successful . I exported the key to some other machine B .It tried to decrypt the web config using that exported key . But it failed saying

    C:\Windows\system32>cd C:\Windows\Microsoft.NET\Framework64\v4.0.30319

C:\Windows\Microsoft.NET\Framework64\v4.0.30319>aspnet_regiis -pi "NewEncryptKey
" "C:\Users\abalawan\Desktop\NewStuartCN\encryptkeynew.xml"
Importing RSA Keys from file..
Succeeded!

C:\Windows\Microsoft.NET\Framework64\v4.0.30319>aspnet_regiis -pa "NewEncryptKey
" "NT AUTHORITY\NETWORK SERVICE"
Adding ACL for access to the RSA Key container...
Succeeded!

C:\Windows\Microsoft.NET\Framework64\v4.0.30319>aspnet_regiis -pdf "connectionSt
rings" "C:\Users\abalawan\Desktop\NewStuartCN"
Decrypting configuration section...
Failed to decrypt using provider 'NewEncryptProvider'. Error message from the pr
ovider: Not enough storage is available to process this command.
 (C:\Users\abalawan\Desktop\NewStuartCN\web.config line 35)

Not enough storage is available to process this command.

Failed!

What am I missing here ? In my machine B while decrypting I tried

cd C:\Windows\Microsoft.NET\Framework64\v4.0.30319

aspnet_regiis -pi "NewEncryptKey" "C:\Users\abalawan\Desktop\NewStuartCN\encryptkeynew.xml"

aspnet_regiis -pa "NewEncryptKey" "NT AUTHORITY\NETWORK SERVICE"

aspnet_regiis -pdf "connectionStrings" "C:\Users\abalawan\Desktop\NewStuartCN"

. Any help will be much appreciated.

You seem to be using the wrong command ( -pdf instead of -pd ):

aspnet_regiis -pdf "connectionStrings" "C:\Users\abalawan\Desktop\NewStuartCN"

should be

aspnet_regiis -pd "connectionStrings" "C:\Users\abalawan\Desktop\NewStuartCN"

https://msdn.microsoft.com/en-us/library/zhhddkxy(v=vs.100).aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM