Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I install a certificate into the local machine store programmatically using c#?

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?

I have a CER file, but can also create a PFX.

like image 759
J Davis Avatar asked Feb 19 '09 18:02

J Davis


1 Answers

I believe that this is correct:

using (X509Store store = new X509Store(StoreName.TrustedPeople, StoreLocation.LocalMachine))  {    store.Open(OpenFlags.ReadWrite);    store.Add(cert); //where cert is an X509Certificate object } 
like image 50
Demi Avatar answered Oct 01 '22 02:10

Demi