加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 资源网站 > 资源 > 正文

加密Web.config Windows Azure

发布时间:2020-12-14 18:43:17 所属栏目:资源 来源:网络整理
导读:我正在使用 Windows Azure的共享网站.我想加密我的web.config部分,但是,我收到此错误: 无法使用提供程序’RsaProtectedConfigurationProvider’解密.来自提供程序的错误消息:无法打开RSA密钥容器. 我的网站中有一个页面会对该文件进行加密,然而,几个小时后
我正在使用 Windows Azure的共享网站.我想加密我的web.config部分,但是,我收到此错误:

无法使用提供程序’RsaProtectedConfigurationProvider’解密.来自提供程序的错误消息:无法打开RSA密钥容器.

我的网站中有一个页面会对该文件进行加密,然而,几个小时后我就会收到此错误.我是否需要将我的机器密钥发送到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();
    }

解决方法

它可能不是您正在寻找的,但您可以使用Azure仪表板中的“配置”选项卡在运行时覆盖AppSettings,以便web.config不存储任何实际的敏感数据.

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

App Settings – Specify name/value pairs that will be loaded by your web application on start up. For .NET sites,these settings will be injected into your .NET configuration AppSettings at runtime,overriding existing settings. For PHP and Node sites these settings will be available as environment variables at runtime.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读