static TestCertificates() { AgentTester.EnsureStandardMachineStores(); ChainCertsStore = LoadCertificateFolder("Chain"); PublicCertsStore = new MemoryX509Store(LoadAllPublic()); AllPublicCerts = LoadAllPublic(); }
public static MemoryX509Store LoadCertificateFolder(string folderPath) { string path = FullPath(folderPath); MemoryX509Store store = new MemoryX509Store(); store.ImportFolder(path, X509KeyStorageFlags.DefaultKeySet); return store; }
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"); }
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; } }
internal MemoryX509Store LoadCerts(X509KeyStorageFlags flags) { MemoryX509Store certStore = new MemoryX509Store(); LoadCerts(certStore, flags); return certStore; }
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; }