如何使用 c# 以编程方式将证书安装到本地机器存储中? [英] How can I install a certificate into the local machine store programmatically using c#?
本文介绍了如何使用 c# 以编程方式将证书安装到本地机器存储中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个通过 MakeCert 生成的证书.我想使用 PeerTrust 将此证书用于 WCF 消息安全.如何使用 c# 或 .NET 以编程方式将证书安装到受信任的人"本地机器证书存储中?
I have a certificate generated via MakeCert. I want to use this certificate for WCF message security using PeerTrust. How can I programmatically install the certificate into the "trusted people" local machine certificate store using c# or .NET?
我有 CER 文件,但也可以创建 PFX.
I have a CER file, but can also create a PFX.
推荐答案
我认为这是正确的:
using (X509Store store = new X509Store(StoreName.TrustedPeople, StoreLocation.LocalMachine))
{
store.Open(OpenFlags.ReadWrite);
store.Add(cert); //where cert is an X509Certificate object
}
这篇关于如何使用 c# 以编程方式将证书安装到本地机器存储中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文