开发者

WCF webconfig encryption issue

开发者 https://www.devze.com 2023-03-13 10:46 出处:网络
I have encrypted my WCF Webconfig, then I have replaced my encrypted webconfig with the actual webconfig file.

I have encrypted my WCF Webconfig, then I have replaced my encrypted webconfig with the actual webconfig file.

Now the problem is project is not working on my pc only, it works fine on other systems.

Encryption is done as follows:

string provider = "RSAProtectedConfigurationProvider"; // or "DataProtectionConfigurationProvider"
string section = "connectionStrings";
protected void EncriptionWebCon开发者_运维问答fig()
{
    System.Configuration.Configuration confg;
    if (HttpContext.Current != null)
        confg = WebConfigurationManager.OpenWebConfiguration("~");
    else
        confg = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

    ConfigurationSection confStrSect = confg.GetSection(section);
    if (confStrSect != null)
    {
        confStrSect.SectionInformation.ProtectSection(provider);
        confg.Save();
    }
}

Error is:

Failed to decrypt using provider 'RsaProtectedConfigurationProvider'. Error message from the provider: The RSA key container could not be opened


The RSA Container and Key are machine specific. Unless you export the container and key from the working machine to the non-working machine it will fail to open the key container. MSDN

0

精彩评论

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