WPF教程

C#程序自动安装数字证书

时间:2014-3-13 17:38:28  作者:WPF之家  来源:http://www.wpf123.com/  查看:823  评论:0
内容摘要:using System.Security.Cryptography.X509Certificates; MessageBox.Show("开始"); //添加个人证书X509Certificate2 certificate = new X509Certificate2...

using System.Security.Cryptography.X509Certificates;

 

MessageBox.Show("开始");

 

//添加个人证书

X509Certificate2 certificate = new X509Certificate2(Application.StartupPath + \cert.pfx","证书密码");
X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadWrite);
store.Remove(certificate);   //可省略
store.Add(certificate);
store.Close();

 

//安装CA的根证书到受信任根证书颁发机构
certificate = new X509Certificate2(Application.StartupPath + "\CA.cer");
store = new X509Store(StoreName.Root, StoreLocation.LocalMachine);
store.Open(OpenFlags.ReadWrite);
store.Remove(certificate);   //可省略
store.Add(certificate);
store.Close();

           
MessageBox.Show("结束");


标签:程序 自动 安装 数字 证书 

原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。本文出自“wpf之家”,请务必保留此出处:http://www.wpf123.com

相关评论
Copyright © 2009-2014 WPF之家(http://www.wpf123.com/) All rights reserved
 Powered by WPF之家
鄂ICP备13006396号