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

推荐订阅源

WordPress大学
WordPress大学
The GitHub Blog
The GitHub Blog
F
Fortinet All Blogs
Cloudbric
Cloudbric
P
Palo Alto Networks Blog
T
Threatpost
T
Tor Project blog
T
Tenable Blog
AWS News Blog
AWS News Blog
Project Zero
Project Zero
L
LangChain Blog
Cyberwarzone
Cyberwarzone
Engineering at Meta
Engineering at Meta
雷峰网
雷峰网
C
CERT Recently Published Vulnerability Notes
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Security Latest
Security Latest
云风的 BLOG
云风的 BLOG
I
Intezer
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
P
Proofpoint News Feed
A
Arctic Wolf
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Google DeepMind News
Google DeepMind News
V
Vulnerabilities – Threatpost
C
Cybersecurity and Infrastructure Security Agency CISA
MongoDB | Blog
MongoDB | Blog
aimingoo的专栏
aimingoo的专栏
K
Kaspersky official blog
Jina AI
Jina AI
N
News | PayPal Newsroom
T
The Blog of Author Tim Ferriss
D
DataBreaches.Net
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
博客园 - 【当耐特】
Hugging Face - Blog
Hugging Face - Blog
Recorded Future
Recorded Future
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
S
Secure Thoughts
TaoSecurity Blog
TaoSecurity Blog
P
Privacy & Cybersecurity Law Blog
P
Proofpoint News Feed
MyScale Blog
MyScale Blog
IT之家
IT之家
Forbes - Security
Forbes - Security
The Hacker News
The Hacker News
Last Week in AI
Last Week in AI
T
Threat Research - Cisco Blogs
Y
Y Combinator Blog

博客园 - AndrewCheng

TableAdapter和多组数据结果 即时查看程序输出的VS插件 让.Net验证控件与自定义验证合作无间 把你的应用程序添加到IE工具栏 - AndrewCheng - 博客园 拦截并分发运行时动态创建控件的事件 程序设计中的调试方法总结 从SQL Server 数据库转换为Access注意事项 昆明喷码机耗材科技有限公司 软件版本后缀所代表的含义 论坛网址 工作格言 C#正则表达式 - AndrewCheng - 博客园 论坛等级分类 - AndrewCheng - 博客园 SQL Server和Oracle的常用函数对比 屏蔽IE浏览器javasccipt的方法 VS2005断开VSS后再次连接上VSS时注意事项 asp.net2.0页面按钮点击无效的解决办法 delegate与event示例程序 C#实现的正余玄函数图象
加密 web.config - AndrewCheng - 博客园
AndrewCheng · 2007-12-13 · via 博客园 - AndrewCheng

1、打开记事本,然后将下面的代码复制到一个新文件中。

<%@ Page Language="C#" %>
<%
Response.Write(System.Security.Principal.WindowsIdentity.GetCurrent().Name);
%> 保存 my.aspx 到你的web目录 ,运行一下窗体显示 “ NT AUTHORITY\NETWORK SERVICE ”。成功!

2、(关键一步)运行cmd,执行以下

aspnet_regiis -pa "NetFrameworkConfigurationKey" "NT AUTHORITY\NETWORK SERVICE"
 

说明:注册默认的 RsaProtectedConfigurationProvider 的RSA 密钥容器,
NetFrameworkConfigurationKey 是 RsaProtectedConfigurationProvider 的默认provider成功!

3、现在,可以加密web.config ,运行:

加密:aspnet_regiis -pe "connectionStrings" -app "/Myweb"
说明:"connectionStrings" 是要加密的节,"/Myweb"是的web目录
解密:aspnet_regiis -pd "connectionStrings" -app "/Myweb"

成功!

4、这样就可以在程序里调用了(不用解密, 哈哈):
...
string connstr= ConfigurationManager.ConnectionStrings["myConnstr"].ConnectionString.ToString();
...

同样的,也可以用创建自己的RSA 密钥容器,如下:
  (1)、创建 "MyKeys" 密钥容器,运行:aspnet_regiis -pc "MyKeys" -exp 
(2)、在web.config里加入以下:
<protectedData>
<providers>
<add name="MyProvider"
type="System.Configuration.RsaProtectedConfigurationProvider, System.Configuration, Version=2.0. 0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d0a3a,
processorArchitecture=MSIL"
keyContainerName="MyKeys"
useMachineContainer="true" />
</providers>
</protectedData>

保存。
(3)、授予帐户对计算机级别的 "MyKeys" RSA 密钥容器的访问权限,运行:

aspnet_regiis -pa "MyKeys" "NT AUTHORITY\NETWORK SERVICE"(4)、现在,可以加密web.config ,运行: 加密aspnet_regiis -pe "connectionStrings" -app "/Myweb" -prov "MyProvider" 说明"connectionStrings" 是要加密的节"/Myweb"是的web目录"MyProvider"

自己密钥容器

解密aspnet_regiis -pd "connectionStrings" -app "/Myweb" -prov "MyProvider"