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

推荐订阅源

Google DeepMind News
Google DeepMind News
Stack Overflow Blog
Stack Overflow Blog
Hugging Face - Blog
Hugging Face - Blog
博客园_首页
T
The Blog of Author Tim Ferriss
博客园 - 叶小钗
N
Netflix TechBlog - Medium
腾讯CDC
C
Check Point Blog
P
Proofpoint News Feed
Engineering at Meta
Engineering at Meta
GbyAI
GbyAI
S
SegmentFault 最新的问题
F
Fortinet All Blogs
美团技术团队
U
Unit 42
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 司徒正美
F
Full Disclosure
Recorded Future
Recorded Future
D
DataBreaches.Net
博客园 - 【当耐特】
Martin Fowler
Martin Fowler
J
Java Code Geeks
I
InfoQ
Y
Y Combinator Blog
A
About on SuperTechFans
AI
AI
爱范儿
爱范儿
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Forbes - Security
Forbes - Security
W
WeLiveSecurity
M
MIT News - Artificial intelligence
雷峰网
雷峰网
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Simon Willison's Weblog
Simon Willison's Weblog
Schneier on Security
Schneier on Security
The GitHub Blog
The GitHub Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
aimingoo的专栏
aimingoo的专栏
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
G
GRAHAM CLULEY
Know Your Adversary
Know Your Adversary
Latest news
Latest news
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
D
Docker
Recent Commits to openclaw:main
Recent Commits to openclaw:main
量子位
V2EX - 技术
V2EX - 技术
Project Zero
Project Zero

博客园 - 冰封王座(.net)博客

实现qq的自动登录 - 冰封王座(.net)博客 - 博客园 创建带签名的cab包的完整流程 对比 javascript url编码 有关 java 与 C#细节不同 - 冰封王座(.net)博客 mysql常用命令 使用 DotnetOpenMail发送带附件的邮件 - 冰封王座(.net)博客 - 博客园 今天你处理异常了么? 防止SQL注入攻击 在DataGrid中进行值映射 - 冰封王座(.net)博客 - 博客园 UML视图使用 想要做个开源 大家谁有创意啊? 程序员每天该做的事 Google SiteMap的作用及协议格式详解[转摘] 取得客户端MAC Java学习之路:不走弯路,就是捷径 开发人员必备网站 Acess 存储与显示图片 css 外层保持固定高度的情况下 能随内层高度自适应变化 新的学习计划(10/8--10/15)
在C#中使用 makecert 创建自签名的证书
冰封王座(.net)博客 · 2007-04-27 · via 博客园 - 冰封王座(.net)博客

 class Program
    
{
        
static void Main(string[] args)
        
{
            X509Certificate2 cert 
= CreateCertificate();
            
//cert.ToString();
            Console.Write(cert.ToString());
            Console.Read();
        }



        
public static X509Certificate2 CreateCertificate()
        
{
            
// makecert -r -pe -n "CN=TestUser" -ss my -sr currentuser 
            
//      -sky exchange .\TestUser.cer

            
//const string MakeCert = "C:\\Program Files\\Microsoft Visual Studio 8\\Common7\\Tools\\Bin\\makecert.exe";
            const string MakeCert = "C:\\Program Files\\Microsoft Visual Studio 8\\SDK\\v2.0\\Bin\\makecert.exe";

            
//string fileName = Path.ChangeExtension(Path.GetTempFileName(), "cer");
            string fileName = Path.ChangeExtension("d:\\""cer");
            
string userName = Guid.NewGuid().ToString();

            
string arguments =
                
string.Format("-r -pe -n \"CN={0}\" -ss my -sr currentuser -sky exchange \"{1}\"",
                userName, fileName);

            Process p 
= Process.Start(MakeCert, arguments);
            p.WaitForExit();

            
byte[] certBytes = ReadFile(fileName);
            X509Certificate2 cert 
= new X509Certificate2(certBytes);
            
return cert;
        }


        
internal static byte[] ReadFile(string fileName)
        
{
            
using (FileStream f = new FileStream(fileName, FileMode.Open, FileAccess.Read))
            
{
                
int size = (int)f.Length;
                
byte[] data = new byte[size];
                size 
= f.Read(data, 0, size);
                
return data;
            }

        }


    }