在我的Windows應用程序,我試圖加密app.config文件的連接字符串的部分,我的app.config文件的連接字符串的部分是使用提供者'RsaProtectedConfigurationProvider'解密失敗?
<connectionStrings>
<add name="SQLiteDB" connectionString="Data Source=|DataDirectory|database.s3db;
Version=3;password=mypassword;" providerName="System.Data.Sqlite"/>
</connectionStrings>
和.cs文件我正在對它進行加密像
Configuration config = ConfigurationManager.OpenExeConfiguration(Application.ExecutablePath);
ConfigurationSection section = config.GetSection("connectionStrings") as ConnectionStringsSection; // could be any section
if (!section.IsReadOnly())
{
section.SectionInformation.ProtectSection("RsaProtectedConfigurationProvider");
section.SectionInformation.ForceSave = true;
config.Save(ConfigurationSaveMode.Full);
}
運行此代碼後,我得到加密的連接字符串在不同的app.config中,此app.config駐留在bin \ debug文件夾中,此.config文件的名稱是nameofapplication.exe.config。
問題是,當我做了這個應用程序的設置,如果提示錯誤,其他計算機上運行:
System.Configuration.ConfigurationErrorsException: Failed to decrypt using provider 'RsaProtectedConfigurationProvider'. Error message from the provider: The RSA key container could not be opened.
我這樣做第一次所以不知道如何解決這個問題,stucked在嚴重它。
僅供參考,或可能是約什導入的鑰匙到其他機器上,在我的案件有關許可。當我在VS上進行調試時無法解密,但在以管理員身份打開VS之後。開始解密它。 – enterbutton 2018-02-07 23:12:56