2011-06-17 52 views
0

我已经加密了我的WCF Webconfig,然后我用实际的webconfig文件替换了我的加密的webconfig。WCF 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密钥容器不能打开

回答

0

的RSA集装箱和关键的是该机的具体。除非您将集装箱和钥匙从工作机器出口到非工作机器,否则将无法打开钥匙包装箱。 MSDN

+0

但我在同一台机器上,它在其他机器上工作,但不在我的机器上 – 2011-06-17 08:33:47

+0

是同一个应用程序加密和解密? – GunnerL3510 2011-06-17 17:33:40