2011-06-17 48 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