【问题标题】:How to encrypt app config and use the application on a network如何加密应用程序配置并在网络上使用应用程序
【发布时间】:2017-02-08 03:32:32
【问题描述】:

我像这样加密了appconfig,在我的计算机上运行良好,但在网络上不起作用

Configuration config = ConfigurationManager.OpenExeConfiguration(exeConfigName);

            ConnectionStringsSection section =
            config.GetSection("connectionStrings")
            as ConnectionStringsSection;

            if (!section.SectionInformation.IsProtected)
            {
                section.SectionInformation.ProtectSection(
                    "DataProtectionConfigurationProvider");

                config.Save();
                ConfigurationManager.RefreshSection("connectionStrings");


            }

【问题讨论】:

  • 什么是“在网络上”?你有错误吗?

标签: c# encryption


【解决方案1】:

DataProtectionConfigurationProvider 依赖于机器。你不能在你的工作站上加密它并期望它默认在服务器上工作。您可以使用RsaProtectedConfigurationProvider 并根据需要导出密钥。或者只是在服务器本身上对其进行加密。

看到这个related SO Question

【讨论】:

  • 你能告诉我如何导入密钥吗??
  • 在我使用 c# linq 的应用程序中,您是否认为第一种方法比另一种方法更好? network 不是在 app.config 中分发连接字符串,而是在用户身份验证后需要连接的信息,该服务可以是 Web 服务或 RESTful 服务。"
  • 另一个问题:如果我像第一种方法一样进行加密,我总是必须共享 appconfig?因为应用程序是在网络上使用的(只有一个安装程序)
猜你喜欢
  • 1970-01-01
  • 2019-02-04
  • 1970-01-01
  • 1970-01-01
  • 2018-01-19
  • 1970-01-01
  • 2011-05-10
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多