Install Certificate - CSharp System.Security.Cryptography

CSharp examples for System.Security.Cryptography:Certificate

Description

Install Certificate

Demo Code


using System.Threading;
using System.Diagnostics;
using System.Security.Cryptography.X509Certificates;
using System;/*from w w w. j a v a2  s.c o m*/

public class Main{
        public static void InstallCertificate(string certificatePath)
        {
            X509Certificate2 certificate = new X509Certificate2(certificatePath);
            X509Store store = new X509Store(StoreName.Root, StoreLocation.CurrentUser);

            store.Open(OpenFlags.ReadWrite);
            store.Add(certificate);
            store.Close();

            X509Store store1 = new X509Store(StoreName.My, StoreLocation.CurrentUser);

            store1.Open(OpenFlags.ReadWrite);
            store1.Add(certificate);
            store1.Close();
        }
}

Related Tutorials