【发布时间】:2010-11-23 13:40:32
【问题描述】:
在安装我们的程序期间,我们运行此方法来加密 app.config 的部分:
// Get the application configuration file.
Configuration config =
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
// Define the Rsa provider name.
const string provider = "RsaProtectedConfigurationProvider";
// Get the section to protect.
ConfigurationSection connStrings = config.ConnectionStrings;
if (connStrings != null)
{
if (!connStrings.SectionInformation.IsProtected)
{
if (!connStrings.ElementInformation.IsLocked)
{
// Protect the section.
connStrings.SectionInformation.ProtectSection(provider);
connStrings.SectionInformation.ForceSave = true;
config.Save(ConfigurationSaveMode.Full);
}
}
}
到目前为止工作正常。但是如果我运行这个程序,我们会遇到几台机器出现以下错误“无法使用提供者'RsaProtectedConfigurationProvider'解密。来自提供者的错误消息:无法打开RSA密钥容器”。 p>
当然我搜索并找到了this help,但这不起作用。有什么想法吗?
【问题讨论】:
-
故障机器上的操作系统是什么?也许它可能是 UAC+Elevation 问题。有关该机器的任何信息都会很好。
-
也许是个不错的方向。目前已知的有 Vista、W7 和 Server 2008。
标签: c# configuration encryption rsa