internal static void InstallCertificate(string certFile, System.Security.Cryptography.X509Certificates.StoreName store, string password) { Logger.EnteringMethod(store.ToString()); try { System.Security.Cryptography.X509Certificates.X509Certificate2 certificate; if (!string.IsNullOrEmpty(password)) { certificate = new System.Security.Cryptography.X509Certificates.X509Certificate2(certFile, password); } else { certificate = new System.Security.Cryptography.X509Certificates.X509Certificate2(certFile); } System.Security.Cryptography.X509Certificates.X509Store certStore = new System.Security.Cryptography.X509Certificates.X509Store(store, System.Security.Cryptography.X509Certificates.StoreLocation.LocalMachine); certStore.Open(System.Security.Cryptography.X509Certificates.OpenFlags.ReadWrite); certStore.Add(certificate); certStore.Close(); Logger.Write("Successfuly imported in " + store.ToString()); } catch (Exception ex) { Logger.Write("**** " + ex.Message); } }
public KeyStoreViewModel(SystemX509.StoreName storeName, SystemX509.StoreLocation storeLocation) { var storeBuilder = new Pkcs12StoreBuilder(); _store = storeBuilder.Build(); Name = String.Format("System KeyStore: [{0} : {1}]", storeLocation.ToString(), storeName.ToString()); Load(storeName, storeLocation); }