Пример #1
0
        MemoryX509Store LoadCertificates(string folderPath)
        {
            if (!Directory.Exists(folderPath))
            {
                throw new DirectoryNotFoundException("Directory not found: " + folderPath);
            }

            MemoryX509Store certStore = new MemoryX509Store();

            try
            {
                string[] files = Directory.GetFiles(folderPath);

                if (files.IsNullOrEmpty())
                {
                    throw new ArgumentException("Empty directory");
                }

                CertificateCommands certcmd = GetCommand <CertificateCommands>();

                foreach (string file in files)
                {
                    certcmd.LoadCerts(certStore, file, "passw0rd!", X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.Exportable | X509KeyStorageFlags.PersistKeySet);
                }

                return(certStore);
            }
            catch
            {
                certStore.Dispose();
                throw;
            }
        }
Пример #2
0
        void EnsureStandardCertsInService(string basePath)
        {
            WriteLine("Installing Private Certs in config service");

            string redmondCertsPath = MakeCertificatesPath(basePath, "redmond");
            string nhindCertsPath   = MakeCertificatesPath(basePath, "nhind");

            CertificateCommands certcmds = GetCommand <CertificateCommands>();

            certcmds.PushCerts(LoadCerts(redmondCertsPath, "Private"), true, EntityStatus.Enabled);
            certcmds.PushCerts(LoadCerts(nhindCertsPath, "Private"), true, EntityStatus.Enabled);

            WriteLine("Installing Anchors in config service");

            AnchorCommands anchorcmds = GetCommand <AnchorCommands>();

            anchorcmds.PushCerts("redmond.hsgincubator.com", LoadCerts(redmondCertsPath, "IncomingAnchors"), true, EntityStatus.Enabled);
            anchorcmds.PushCerts("redmond.hsgincubator.com", LoadCerts(redmondCertsPath, "OutgoingAnchors"), true, EntityStatus.Enabled);
            anchorcmds.PushCerts("nhind.hsgincubator.com", LoadCerts(nhindCertsPath, "IncomingAnchors"), true, EntityStatus.Enabled);
            anchorcmds.PushCerts("nhind.hsgincubator.com", LoadCerts(nhindCertsPath, "OutgoingAnchors"), true, EntityStatus.Enabled);
        }