0

我已经加密了我的 WCF Webconfig,然后我用实际的 webconfig 文件替换了我的加密 webconfig。

现在的问题是项目不能只在我的电脑上运行,它在其他系统上运行良好。

加密如下:

string provider = "RSAProtectedConfigurationProvider"; // or "DataProtectionConfigurationProvider"
string section = "connectionStrings";
protected void EncriptionWebConfig()
{
    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();
    }
}

错误是:

无法使用提供程序“RsaProtectedConfigurationProvider”解密。来自提供者的错误消息:无法打开 RSA 密钥容器

4

1 回答 1

0

RSA 容器和密钥是特定于机器的。除非您将容器和密钥从工作机器导出到非工作机器,否则将无法打开密钥容器。 MSDN

于 2011-06-17T08:21:33.093 回答