【问题标题】:Need Encrypted connection string and stmp information in the web.config需要 web.config 中的加密连接字符串和 stmp 信息
【发布时间】:2010-11-22 04:55:22
【问题描述】:

我想在 web.config 中保留加密的连接字符串和 stmp 信息。

我可以将连接字符串和 SMTP 信息存储在加密的 web.config 中,并且我只需要解密和使用吗?

我可以加密连接字符串和 SMTP 并保存在 web.config 中的点/事件是什么? (如果更改发生在 web.config 中,现有会话是否已过期?)

什么是最好的解决方案?

谢谢

【问题讨论】:

    标签: asp.net connection-string encryption


    【解决方案1】:

    使用aspnet_regiis.exe 很容易 - 查看 pe/pd/pef 和 pdf 选项。你也可以这样做programmatically。它通过加密特定的配置部分来工作。在您的情况下,这是 connectionStringssmtp 部分。

    您可以使用DPAPIRSA,并且可以在机器范围内或特定用户帐户上进行加密。

    【讨论】:

    • 我在以编程方式更改使用时使用此代码,但出现错误,我在开发环境中
    • public void ProtectSection() { System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(Server.MapPath("~/Web.config")); ConfigurationSection 部分 = config.GetSection("connectionStrings"); section.SectionInformation.ProtectSection("RsaProtectedConfigurationProvider"); section.SectionInformation.ForceSave = true; config.Save(ConfigurationSaveMode.Full); }
    • 你能检查一下是什么问题吗,我会感谢你的努力
    • 您遇到的错误是什么?如果您在 Web 应用程序中执行此操作,作为一个附带问题,您应该查看 WebConfigurationManager.OpenWebConfiguration msdn.microsoft.com/en-us/library/ms151456.aspx
    • 我收到此错误。执行 connectionStrings 的配置节处理程序时出错。
    猜你喜欢
    • 2011-08-19
    • 2012-06-18
    • 2010-12-14
    • 1970-01-01
    • 2012-05-31
    • 1970-01-01
    • 2011-06-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多