繁体   English   中英

加密Web.Config

[英]Encrypting Web.Config

用于部署.NET加密配置文件以进行部署加密配置文件重复


在web.config文件中加密信息的最佳方法和工具是什么?

以下是无需编程即可加密web.config文件的命令...

用于加密

aspnet_regiis -pef "Section" "Path exluding web.config"

对于解密

aspnet_regiis -pdf "Section" "Path exluding web.config"

通过此命令,您可以加密或解密所有部分。

我相信有两种方法可以做到这一点:

使用DPAPIRSA使用aspnet_regi,或以编程方式执行

编程方式可以很方便,特别是如果您还想加密app.config。

根据我使用它的经验,如果您编写自定义配置部分,则已将包含该部分的类的DLL安装到GAC中。 对于我正在工作的项目,我基本上编写了以下方法:

  • 将配置DLL复制到GAC。
  • 执行加密。
  • 从GAC中删除配置DLL。

如果您只是加密连接字符串,那么这可能不会成为问题。 您还需要记住是要在机器范围内加密还是在特定用户帐户加密 - 根据您的情况,这两个选项都很有用。 为简单起见,我坚持使用机器加密。 我提供的链接解释了两种方法的优点。

在框架目录中使用aspnet_regiis工具:

                                        -- CONFIGURATION ENCRYPTION OPTIONS --

pe section            Encrypt the configuration section. Optional arguments:
                      [-prov provider] Use this provider to encrypt.
                      [-app virtual-path] Encrypt at this virtual path. Virtual path must begin with a forward slash.
                      If it is '/', then it refers to the root of the site. If -app is not specified, the root
                      web.config will be encrypted.
                      [-site site-name-or-ID] The site of the virtual path specified in -app. If not specified, the
                      default web site will be used.
                      [-location sub-path] Location sub path.
                      [-pkm] Encrypt/decrypt the machine.config instead of web.config.

pd section            Decrypt the configuration section. Optional arguments:
                      [-app virtual-path] Decrypt at this virtual path. Virtual path must begin with a forward slash.
                      If it is '/', then it refers to the root of the site. If -app is not specified, the root
                      web.config will be decrypted.
                      [-site site-name-or-ID] The site of the virtual path specified in -app. If not specified, the
                      default web site will be used.
                      [-location sub-path] Location sub path.
                      [-pkm] Encrypt/decrypt the machine.config instead of web.config.

您应该从这里开始,易于理解,在MSDN中详细解释分步指南: 如何:使用DPAPI加密ASP.NET 2.0中的配置部分

使用aspnet_regiis.exe命令行工具

您还可以使用aspnet_regiis.exe命令行工具加密和解密Web.config文件中的部分,该工具可以在%WINDOWSDIR%\\ Microsoft.Net \\ Framework \\ version目录中找到。

请看这里: http//aspnet.4guysfromrolla.com/articles/021506-1.aspx

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM