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

推荐订阅源

V
Vulnerabilities – Threatpost
U
Unit 42
F
Fortinet All Blogs
aimingoo的专栏
aimingoo的专栏
P
Proofpoint News Feed
F
Full Disclosure
月光博客
月光博客
Engineering at Meta
Engineering at Meta
博客园_首页
The Register - Security
The Register - Security
G
Google Developers Blog
The Cloudflare Blog
博客园 - Franky
K
Kaspersky official blog
A
Arctic Wolf
Scott Helme
Scott Helme
C
Cisco Blogs
Hugging Face - Blog
Hugging Face - Blog
C
Check Point Blog
NISL@THU
NISL@THU
AI
AI
D
DataBreaches.Net
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Stack Overflow Blog
Stack Overflow Blog
Project Zero
Project Zero
The GitHub Blog
The GitHub Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
量子位
Vercel News
Vercel News
T
Tor Project blog
P
Privacy International News Feed
D
Docker
I
Intezer
L
LangChain Blog
P
Proofpoint News Feed
Security Latest
Security Latest
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threatpost
博客园 - 聂微东
AWS News Blog
AWS News Blog
Martin Fowler
Martin Fowler
P
Privacy & Cybersecurity Law Blog
V
V2EX
Last Week in AI
Last Week in AI
C
Cybersecurity and Infrastructure Security Agency CISA
The Hacker News
The Hacker News
T
Tenable Blog
Blog — PlanetScale
Blog — PlanetScale
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog

博客园 - 冰封王座(.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;
            }

        }


    }