Fehler beim Entschlüsseln mit dem Anbieter 'RsaProtectedConfigurationProvider'?
In meiner Windows-Anwendung versuche ich, den Verbindungszeichenfolgenabschnitt der app.config-Datei zu verschlüsseln. Der Verbindungszeichenfolgenteil meiner app.config-Datei ist
<connectionStrings>
<add name="SQLiteDB" connectionString="Data Source=|DataDirectory|database.s3db;
Version=3;password=mypassword;" providerName="System.Data.Sqlite"/>
</connectionStrings>
und in .cs Datei verschlüssele ich es wie
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);
}
Nach dem Ausführen dieses Codes erhalte ich eine verschlüsselte Verbindungszeichenfolge in einer anderen app.config. Diese app.config befindet sich im Ordner bin \ debug, und der Name dieser .config-Datei lautet nameofapplication.exe.config.
Das Problem ist, wenn ich Setup dieser Anwendung gemacht und auf einem anderen Computer ausgeführt, wenn Fehler gibt, dass:
System.Configuration.ConfigurationErrorsException: Failed to decrypt using provider 'RsaProtectedConfigurationProvider'. Error message from the provider: The RSA key container could not be opened.
Ich mache es zum ersten Mal, weiß also nicht, wie ich es lösen soll, steckte schlecht darin fest.