我怎样才能证书安装到本地计算机存储编程方式使用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.
推荐答案
我相信这是正确的:
X509Store store = new X509Store(StoreName.TrustedPeople, StoreLocation.LocalMachine);
store.Open(OpenFlags.ReadWrite);
store.Add(cert); //where cert is an X509Certificate object
store.Close();
这篇关于我怎样才能证书安装到本地计算机存储编程方式使用C#?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文