惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

宝玉的分享
宝玉的分享
NISL@THU
NISL@THU
E
Exploit-DB.com RSS Feed
L
LINUX DO - 热门话题
L
Lohrmann on Cybersecurity
K
Kaspersky official blog
Project Zero
Project Zero
Cisco Talos Blog
Cisco Talos Blog
T
The Exploit Database - CXSecurity.com
P
Palo Alto Networks Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threatpost
S
Schneier on Security
G
GRAHAM CLULEY
The Hacker News
The Hacker News
T
Threat Research - Cisco Blogs
Scott Helme
Scott Helme
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
P
Privacy & Cybersecurity Law Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
Cyberwarzone
Cyberwarzone
C
CERT Recently Published Vulnerability Notes
T
Tor Project blog
AWS News Blog
AWS News Blog
Simon Willison's Weblog
Simon Willison's Weblog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
爱范儿
爱范儿
P
Privacy International News Feed
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
S
Securelist
G
Google Developers Blog
The Last Watchdog
The Last Watchdog
Google Online Security Blog
Google Online Security Blog
美团技术团队
F
Fortinet All Blogs
小众软件
小众软件
Recorded Future
Recorded Future
V
Visual Studio Blog
B
Blog RSS Feed
H
Help Net Security
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Google DeepMind News
Google DeepMind News
Blog — PlanetScale
Blog — PlanetScale
博客园 - 聂微东
Stack Overflow Blog
Stack Overflow Blog
Martin Fowler
Martin Fowler
Latest news
Latest news
Spread Privacy
Spread Privacy
H
Heimdal Security Blog

博客园 - 玄新

Windows DNA架构 如何使用 Visual C# .NET 检查 Windows 版本[转] 使用DirectoryServices给文件添加访问权限 - 玄新 - 博客园 使用WMI来获取CPU序列号 - 玄新 - 博客园 什么是WMI C#读取设备信息(源代码下载) 格式化日期型数据 用 javascript显示时间日期代码(来自网上) - 玄新 - 博客园 昨天发现System.Diagnostics.Process 一样的可以打开一个网页的,直接的输入网页的地址就好了 - 玄新 - 博客园 文本框输入限制大全 在b/s开发中经常用到的javaScript技术 - 玄新 文本框里只能输入数字和退格键 (datagridview)如果单击列表头,全选.(第一列为复选框) DataGridView新特色(vs2005) 实现窗体淡入淡出的完整代码 excel 导入导出access数据库(winform) 递归得到叶子节点。 验证手机号码,小灵通号码函数 - 玄新 如何在SQL中对行进行动态编号 - 玄新
asp.net 2.0 中加密web.config 文件中的配置节
玄新 · 2007-02-01 · via 博客园 - 玄新

在asp.net2.0中新增了对web.config中的部分数据进行加密的功能,可以使用RSAProtectedConfigurationProvider和DPAPIProtectedConfigurationProvider来加密,本文说明使用RSAProtectedConfigurationProvidert和计算机级别的密钥容器进行加密的步骤。

1.         首先确定要进行加密的web.config中的配置节是否可以加密

2.         创建RSA密钥容器

3.         在web.config中标识要使用的密钥容器

4.         对web.config进行加密

5.         授予对 RSA 密钥容器的访问权限

Step 1:首先确定要进行加密的web.config中的配置节是否可以加密
ASP.NET 2.0支持对Web.config的部分配置节进行加密,以下配置节中的数据是不能进行加密的:

<processModel>
<runtime>
<mscorlib>
<startup>
<system.runtime.remoting>
<configProtectedData>
<satelliteassemblies>
<cryptographySettings>
<cryptoNameMapping>
<cryptoClasses>
 

Step2:创建 RSA 密钥容器
若要创建 RSA 密钥容器,请使用 ASP.NET IIS 注册工具 (Aspnet_regiis.exe) 及 –pc 开关。必须为密钥容器指定一个名称,该名称标识应用程序的 Web.config 文件的 configProtectedData 节中指定的 RsaProtectedConfigurationProvider 所使用的密钥容器。为确保可以导出新创建的 RSA 密钥容器,必须包括 -exp 选项。

例如,下面的命令创建一个名为 ABeenKeys 的 RSA 密钥容器,该容器是可导出的计算机级密钥容器。

aspnet_regiis -pc "ABeenKeys"–exp

Step 3: Modify web.config to identify the key container
编辑Web.config文件以标识要使用的密钥容器

在web.config中加以<configProtectedData>来配置密钥容器, 使用名为 ABeenKeys 的计算机级 RSA 密钥容器的
在<configuration>中加入xmlns属性


<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">使用名为 ABeenKeys 的计算机级 RSA 密钥容器的 saProtectedConfigurationProvider。
  <configProtectedData >    <providers>      <add name="ABeenProvider"       type="System.Configuration.RsaProtectedConfigurationProvider, System.Configuration, Version=2.0.0.0,Culture=neutral, processorArchitecture=MSIL"      keyContainerName="ABeenKeys"/>    </providers>  </configProtectedData>
Step 4: Encrypt the <connectionStrings> section of your web.config file
加密你的web.config文件中的配置节

> aspnet_regiis -pe "connectionStrings" -app "/connectionTest" 
 
Step 5:授予对 RSA 密钥容器的访问权限
可以通过以下代码确定应该给哪个用户权限

Response.Write(System.Security.Principal.WindowsIdentity.GetCurrent().Name);
默认情况下,RSA 密钥容器受到所在服务器上的 NTFS 访问控制列表 (ACL) 的严密保护。这样能够限制可以访问加密密钥的人员,从而增强加密信息的安全性。必须首先向 ASP.NET 应用程序的进程标识授予对该 RSA 密钥容器的读取访问权限,然后 ASP.NET 才能使用 RSA 密钥容器。可以使用 Aspnet_regiis.exe 工具及 -pa 开关,向 ASP.NET 应用程序的标识授予读取 RSA 密钥容器的权限。例如,下面的命令向 Windows Server 2003 NETWORK SERVICE 帐户授予对名为 ABeenKeys 的计算机级 RSA 密钥容器的读取访问权限:

aspnet_regiis -pa "ABeenKeys" "NT AUTHORITY\NETWORK SERVICE"
注意:
 
如果 RSA 密钥容器是用户级容器,必须以其 Windows 配置文件存储了密钥的用户的身份登录,并且必须包括 -pku 选项以授予对该用户级 RSA 密钥容器的访问权限。
 

若要使用计算机配置中指定的默认 RsaProtectedConfigurationProvider,必须首先向应用程序的 Windows 标识授予对名为 NetFrameworkConfigurationKey 的计算机密钥容器的访问权限,该计算机密钥容器是为该默认提供程序指定的密钥容器。例如,下面的命令向 NETWORK SERVICE 帐户授予对默认 RsaProtectedConfigurationProvider 所使用的 RSA 密钥容器的访问权限。

aspnet_regiis -pa "NetFrameworkConfigurationKey" "NT AUTHORITY\NETWORK SERVICE"
NetFrameworkConfigurationKey RSA 密钥容器是 Aspnet_regiis.exe 工具所发出的命令的默认密钥容器。因此上述命令也可以按以下方式发出:

aspnet_regiis -pa "NT AUTHORITY\NETWORK SERVICE"

代码下载https://files.cnblogs.com/abeen/connectionTest.rar
注意:我发现这个方法有个缺陷,哪就是在每次加密完后,重新启动机算机发现IIS admin出错了,还得重新安装 iis  郁闷