Asp.net Web应用程序工具-应用程序设置。 SQL 凭据?

发布于 2024-08-28 00:13:35 字数 79 浏览 7 评论 0原文

只是想知道将用户名和密码放在应用程序设置中是否是个好主意?

如果不是,存放这些物品的最佳地点在哪里?

——琼斯

Just wandering if its a good idea to put username and password in the application settings?

If not where is the best place to store these?

--Jonesy

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一个人的夜不怕黑 2024-09-04 00:13:35

由于 web.config 是受保护的文件,因此无法直接访问它。您可能可以将连接凭据存储在那里。

但是 - 您可以更进一步,加密 web.config 中的 appSettings

演练:使用受保护的配置加密配置信息

Since web.config is a protected file there will be no direct access to it. You will probably be fine storing your connection credentials there.

However - You can go a bit further and encrypt the appSettings in your web.config

Walkthrough: Encrypting Configuration Information Using Protected Configuration

挽袖吟 2024-09-04 00:13:35

配置文件将是保存有关数据库凭据的详细信息的理想位置。但是,如果您担心其以纯文本形式存储的安全性,那么在 ASP.NET 中,您可以加密 Web 配置文件的特定部分。加密可以是通过提供相关的命令行参数来使用 aspnet_regiis.exe 实用程序来完成。或者,也可以在“WebConfigurationManager”类的帮助下通过代码来完成加密。而且,您不需要取消保护为了读取该部分中的配置设置,运行时将执行应用程序读取纯文本值所需的解密。

例如:- aspnet_regiis.exe

C:\>aspnet_regiis -pdf "connectionStrings" "C:\Projects\My Site"

这里的 pdf 参数用于指定文件路径。

例如:- 使用 WebConfigurationManager

protected void toggleEncryption(object sender, EventArgs e)
{
    Configuration config;
    config = WebConfigurationManager.OpenWebConfiguration("~");
    ConnectionStringsSection section;
    section = config.GetSection("connectionStrings")
        as ConnectionStringsSection;
    if (section.SectionInformation.IsProtected)
    {
        section.SectionInformation.UnprotectSection();
    }
    else
    {
        section.SectionInformation.ProtectSection(
            "DataProtectionConfigurationProvider");
    }
    config.Save();
    WriteMessage("connections protected = " +
    section.SectionInformation.IsProtected);
}

Configuration files will be an ideal place for keeping the details about the database credential.But if you are worried about its security as its stored in plain text , then in asp.net you can encrypt a particular section of your webconfig file.Encyption can be done either by making use of aspnet_regiis.exe utility by providing relevant command line arguments.Otherwise encryption can also be done through code with the help of "WebConfigurationManager" class.Also You don’t need to unprotect a section in order to read the configuration settings in that section, the runtime will perform the decryption necessary for your application to read the plain text values.

E.g :- aspnet_regiis.exe

C:\>aspnet_regiis -pdf "connectionStrings" "C:\Projects\My Site"

here pdf argument is used to specify file path.

E.g :- Using WebConfigurationManager

protected void toggleEncryption(object sender, EventArgs e)
{
    Configuration config;
    config = WebConfigurationManager.OpenWebConfiguration("~");
    ConnectionStringsSection section;
    section = config.GetSection("connectionStrings")
        as ConnectionStringsSection;
    if (section.SectionInformation.IsProtected)
    {
        section.SectionInformation.UnprotectSection();
    }
    else
    {
        section.SectionInformation.ProtectSection(
            "DataProtectionConfigurationProvider");
    }
    config.Save();
    WriteMessage("connections protected = " +
    section.SectionInformation.IsProtected);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文