Ejemplo n.º 1
0
        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);
                }
            }
        }
Ejemplo n.º 2
0
        public void AnchorAddMachine(string[] args)
        {
            CertificateFileInfo certFileInfo = CertificateFileInfo.Create(0, args);

            using (SystemX509Store store = SystemX509Store.OpenAnchorEdit())
            {
                store.ImportKeyFile(certFileInfo.FilePath, certFileInfo.Password, X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.Exportable | X509KeyStorageFlags.PersistKeySet);
            }
        }
Ejemplo n.º 3
0
        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");
            }
        }
Ejemplo n.º 4
0
        /// <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));
            }
        }
Ejemplo n.º 5
0
        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"));
            }
        }