我正在使用来自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();
}发布于 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站点,这些设置将在运行时作为环境变量提供。
发布于 2015-01-02 18:31:19
我不确定在你提问的时候这是否可用,但是微软的一位工程师为Windows Azure设计了一个新的ProtectedConfigurationProvider。下面是它的链接:https://code.msdn.microsoft.com/Encrypt-Configuration-5a8e8dfe#content。
他们已经提供了关于在here上到底要做什么的详细步骤。
https://stackoverflow.com/questions/15026059
复制相似问题