public void ResetStores(string[] args) { SystemX509Store store; WriteLine("Removing all Machine Private Certs"); using (store = SystemX509Store.OpenPrivateEdit()) { foreach (var certificate in store.GetAllCertificates()) { store.Remove(certificate); } } WriteLine("Removing all Machine Public Certs"); using (store = SystemX509Store.OpenExternalEdit()) { foreach (var certificate in store.GetAllCertificates()) { store.Remove(certificate); } } WriteLine("Removing all Machine Anchors Certs"); using (store = SystemX509Store.OpenAnchorEdit()) { foreach (var certificate in store.GetAllCertificates()) { store.Remove(certificate); } } }
public void EnsureMachineStores(string[] args) { SystemX509Store store = null; using (store = SystemX509Store.OpenPrivateEdit()) { WriteLine("Created Private Store"); } using (store = SystemX509Store.OpenExternalEdit()) { WriteLine("Created Public Store"); } using (store = SystemX509Store.OpenAnchorEdit()) { WriteLine("Created Anchor Store"); } }
private static SystemX509Store OpenStore(string storeName) { SystemX509Store store; switch (storeName.ToLower()) { case "public": store = SystemX509Store.OpenExternalEdit(); break; case "private": store = SystemX509Store.OpenPrivateEdit(); break; default: throw new ArgumentException(storeName); } return(store); }
void EnsureStandardMachineStores(string path) { SystemX509Store.CreateAll(); string basePath = path; string redmondCertsPath = MakeCertificatesPath(basePath, "redmond"); string nhindCertsPath = MakeCertificatesPath(basePath, "nhind"); string noAnchorCertsPath = MakeCertificatesPath(basePath, "noAnchor"); SystemX509Store store; WriteLine("Installing Private Certs"); using (store = SystemX509Store.OpenPrivateEdit()) { InstallCerts(store, LoadCerts(redmondCertsPath, "Private")); InstallCerts(store, LoadCerts(nhindCertsPath, "Private")); } WriteLine("Installing Public Certs"); using (store = SystemX509Store.OpenExternalEdit()) { InstallCerts(store, LoadCerts(redmondCertsPath, "Public")); InstallCerts(store, LoadCerts(nhindCertsPath, "Public")); InstallCerts(store, LoadCerts(noAnchorCertsPath, "Public")); } WriteLine("Installing Anchors Certs"); using (store = SystemX509Store.OpenAnchorEdit()) { InstallCerts(store, LoadCerts(redmondCertsPath, "IncomingAnchors")); InstallCerts(store, LoadCerts(redmondCertsPath, "OutgoingAnchors")); InstallCerts(store, LoadCerts(nhindCertsPath, "IncomingAnchors")); InstallCerts(store, LoadCerts(nhindCertsPath, "OutgoingAnchors")); } }