示例#1
0
 static TestCertificates()
 {
     AgentTester.EnsureStandardMachineStores();
     ChainCertsStore = LoadCertificateFolder("Chain");
     PublicCertsStore = new MemoryX509Store(LoadAllPublic());
     AllPublicCerts = LoadAllPublic();
 }
示例#2
0
        public static MemoryX509Store LoadCertificateFolder(string folderPath)
        {
            string path = FullPath(folderPath);
            MemoryX509Store store = new MemoryX509Store();
            store.ImportFolder(path, X509KeyStorageFlags.DefaultKeySet);

            return store;
        }
示例#3
0
 public TrustChainTests()
 {
     m_store = TestCertificates.ChainCertsStore.Clone();
     m_resolver = m_store.CreateResolver();
     m_validator = this.CreateValidator();
     //
     // Find the endcert and the root cert
     // We'll trust the root cert, but the intermediaries are not trusted
     //            
     m_endCerts = m_resolver.GetCertificates(new MailAddress("*****@*****.**"));
     m_trustedAnchors = m_resolver.GetCertificatesForDomain("root.xyz");
 }
示例#4
0
        internal void LoadCerts(MemoryX509Store certStore, X509KeyStorageFlags flags)
        {
            if (!File.Exists(this.FilePath))
            {
                throw new FileNotFoundException("File does not exist", this.FilePath);
            }
            
            string ext = Path.GetExtension(this.FilePath) ?? string.Empty;
            switch (ext.ToLower())
            {
                default:
                    certStore.ImportKeyFile(this.FilePath, flags);
                    break;

                case ".pfx":
                    certStore.ImportKeyFile(FilePath, this.Password, flags);
                    break;
            }
        }
示例#5
0
 internal MemoryX509Store LoadCerts(X509KeyStorageFlags flags)
 {
     MemoryX509Store certStore = new MemoryX509Store();
     LoadCerts(certStore, flags);
     return certStore;
 }
示例#6
0
        MemoryX509Store LoadCertificates(string folderPath)
        {
            if (!Directory.Exists(folderPath))
            {
                throw new DirectoryNotFoundException("Directory not found: " + folderPath);
            }

            MemoryX509Store certStore = new MemoryX509Store();
            string[] files = Directory.GetFiles(folderPath);
            if (ArrayExtensions.IsNullOrEmpty(files))
            {
                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;
        }