C#程序自动安装数字证书 祥细怎样编写的。我怎总是出错。
usingSystem.Security.Cryptography.X509Certificates;MessageBox.Show("开始");//添加个人证书X509...
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("结束");
代码以上。。 展开
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("结束");
代码以上。。 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询