7

Windows Azure の共有 Web サイトを使用しています。web.config の一部を暗号化したいのですが、次のエラーが発生します。

プロバイダー 'RsaProtectedConfigurationProvider' を使用して復号化できませんでした。プロバイダーからのエラー メッセージ: RSA キー コンテナーを開けませんでした。

サイトにそのファイルを暗号化するページがありますが、数時間後にこのエラーが発生します。マシン キーを Azure に送信する必要がありますか? または、使用できるものを Azure が持っていますか?

構成ファイルを暗号化するには、次のコードを使用します。

    /// <summary>
    /// About view for the website.
    /// </summary>
    /// <returns>Action Result.</returns>
    public ActionResult About()
    {
        Configuration objConfig =
          WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);
        AppSettingsSection objAppsettings =
          (AppSettingsSection)objConfig.GetSection("appSettings");
        if (!objAppsettings.SectionInformation.IsProtected)
        {
            objAppsettings.SectionInformation.ProtectSection(
                           "RsaProtectedConfigurationProvider");
            objAppsettings.SectionInformation.ForceSave = true;
            objConfig.Save(ConfigurationSaveMode.Modified);
        }

        return View();
    }
4

2 に答える 2

4

まさにあなたが探しているものではないかもしれませんが、Azure ダッシュボードの [構成] タブを使用して、実行時に AppSettings を上書きし、web.config に実際の機密データが保存されないようにすることができます。

http://www.windowsazure.com/en-us/manage/services/web-sites/how-to-configure-websites/#howtochangeconfig

アプリの設定 – 起動時に Web アプリケーションによって読み込まれる名前と値のペアを指定します。.NET サイトの場合、これらの設定は実行時に .NET 構成の AppSettings に挿入され、既存の設定が上書きされます。PHP および Node サイトの場合、これらの設定は実行時に環境変数として使用できます。

于 2013-03-11T18:20:08.863 に答える
2

質問の時点でこれが利用可能だったかどうかはわかりませんが、Microsoft のエンジニアが Windows Azure 専用の新しい ProtectedConfigurationProvider を考え出しました。これへのリンクは次のとおりです: https://code.msdn.microsoft.com/Encrypt-Configuration-5a8e8dfe#content

彼らは、ここで何をすべきかについて詳細な手順を提供しています。

于 2015-01-02T10:31:19.437 に答える