/// <summary> /// Sets up standard stores for Testing /// WARNING: This may require elevated permissions /// </summary> public static void EnsureStandardMachineStores() { SystemX509Store.CreateAll(); string basePath = Directory.GetCurrentDirectory(); string redmondCertsPath = MakeCertificatesPath(basePath, "redmond"); string nhindCertsPath = MakeCertificatesPath(basePath, "nhind"); X509Store privateStore = CryptoUtility.OpenStoreReadWrite(SystemX509Store.PrivateCertsStoreName, StoreLocation.LocalMachine); if (!DoPrivateKeysExist(privateStore, redmondCertsPath)) { InstallPrivateKeys(privateStore, LoadPrivateCerts(redmondCertsPath, true)); } if (!DoPrivateKeysExist(privateStore, nhindCertsPath)) { InstallPrivateKeys(privateStore, LoadPrivateCerts(nhindCertsPath, true)); } privateStore.Close(); SystemX509Store store; using (store = SystemX509Store.OpenExternalEdit()) { InstallCerts(store, LoadPublicCerts(redmondCertsPath)); InstallCerts(store, LoadPublicCerts(nhindCertsPath)); } using (store = SystemX509Store.OpenAnchorEdit()) { InstallCerts(store, LoadIncomingAnchors(redmondCertsPath)); InstallCerts(store, LoadOutgoingAnchors(redmondCertsPath)); InstallCerts(store, LoadIncomingAnchors(nhindCertsPath)); InstallCerts(store, LoadOutgoingAnchors(nhindCertsPath)); } }
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")); } }
public void EnsureStandardMachineStores() { SystemX509Store.CreateAll(); }