我已经加密了我的 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 密钥容器