0

WCF Webconfig を暗号化してから、暗号化された Webconfig を実際の Webconfig ファイルに置き換えました。

現在、問題はプロジェクトが私のPCでのみ機能していないことです。他のシステムでは正常に機能します。

暗号化は次のように行われます。

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 キー コンテナーを開けませんでした

4

1 に答える 1

0

RSA コンテナとキーはマシン固有です。動作中のマシンから非動作中のマシンにコンテナとキーをエクスポートしない限り、キー コンテナを開くことができません。 MSDN

于 2011-06-17T08:21:33.093 に答える