首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >加密Web.config Web.config

加密Web.config Web.config
EN

Stack Overflow用户
提问于 2013-02-22 22:10:26
回答 2查看 1.8K关注 0票数 7

我正在使用来自Windows Azure的共享网站。我想要加密我的web.config的一部分,但是,我得到了这个错误:

无法使用提供程序'RsaProtectedConfigurationProvider‘进行解密。来自提供程序的错误消息:无法打开RSA密钥容器。

我在我的网站上有一个页面,它将加密该文件,但是,几个小时后,我收到了这个错误。我是否需要将我的计算机密钥发送到Azure,或者他们是否有我可以使用的密钥?

为了加密我的配置文件,我使用以下代码:

代码语言:javascript
复制
    /// <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();
    }
EN

回答 2

Stack Overflow用户

发布于 2013-03-12 02:20:09

这可能不是你想要的,但你可以使用Azure仪表板中的Configuration选项卡在运行时覆盖AppSettings,这样web.config就不会存储任何实际的敏感数据。

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

应用程序设置-指定将由web应用程序在启动时加载的名称/值对。对于.NET站点,这些设置将在运行时注入到.NET configuration AppSettings中,覆盖现有设置。对于PHP和Node站点,这些设置将在运行时作为环境变量提供。

票数 4
EN

Stack Overflow用户

发布于 2015-01-02 18:31:19

我不确定在你提问的时候这是否可用,但是微软的一位工程师为Windows Azure设计了一个新的ProtectedConfigurationProvider。下面是它的链接:https://code.msdn.microsoft.com/Encrypt-Configuration-5a8e8dfe#content

他们已经提供了关于在here上到底要做什么的详细步骤。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15026059

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档