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

            return store;
        }
Example #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");
 }
Example #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;
            }
        }
Example #5
0
 internal MemoryX509Store LoadCerts(X509KeyStorageFlags flags)
 {
     MemoryX509Store certStore = new MemoryX509Store();
     LoadCerts(certStore, flags);
     return certStore;
 }
Example #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;
        }