开发者

.NET web.config encryption failing!

Here i开发者_开发知识库s what I do:

//First delete 
aspnet_regiis -pz MyKeyName 
//Create the container
aspnet_regiis -pc MyKeyName -exp
//Install the key into a machine-level RSA key provider 
aspnet_regiis -pi MyKeyName pathToKeyFile
//Encrypt
aspnet_regiis -pef "connectionStrings" -prov pathToWebConfigFile

//So that's all good so far. If I want I can now decrypt which runs just fine on the same machine:
aspnet_regiis -pdf "connectionStrings" 

I now take the Encrypted file and bring it to another machine and instal the same key (got from exporting my key using aspnet_regiis -px "MyKeyName" "C:\MyKeyName.xml" -pri).

Now when I run the same decryption command I get an error " Decryption failed... Bad Data..."

What am i missing here???


With any encryption there will be a public and private key. The private key used to encrypt the data contained in the Web.config file isn't actually written inside that file. This means that if you copy the encrypted Web.config from one server to another, the second server will be unable to decrypt the information.

Basically you have to encrypt and descrypt on the same server.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜