public void GetCertificateAsync_NullThumbprint_ExceptionThrown() { var rdr = new PemParsingCertificateReader(); Action a = () => rdr.GetCertificateAsync(null); a.Should().Throw <ArgumentNullException>(); }
public async Task GetCertificateAsync_EmptyThumbprint_NullReturned() { var rdr = new PemParsingCertificateReader(); var result = await rdr.GetCertificateAsync(""); result.Should().BeNull(); }
public async Task GetCertificateAsync__KeyPair_NullReturned() { var keyPair = TestCertificateGenerator.GenerateKeyPair(); using (var originCert = TestCertificateGenerator.GenerateCertificate(keyPair, "test", null)) { var pem = TestCertificateGenerator.GetPemTextFromPublicKey(keyPair); var rdr = new PemParsingCertificateReader(); var result = await rdr.GetCertificateAsync(pem); result.Should().BeNull(); } }
public async Task GetCertificateAsync_CertInPemThumbprint_NonNullReturned() { var keyPair = TestCertificateGenerator.GenerateKeyPair(); using (var originCert = TestCertificateGenerator.GenerateCertificate(keyPair, "test", null)) { var cert = TestCertificateGenerator.ToX509V2Cert(originCert); var pem = TestCertificateGenerator.GetPemTextFromCertificate(cert); var rdr = new PemParsingCertificateReader(); var result = await rdr.GetCertificateAsync(pem); result.Should().NotBeNull(); } }
private async Task <IEnumerable <X509Certificate2> > GetServerCertificatesAsync() { KeySecret[] pems = await GetThirdPartyCertificateNames() .Select(_keySecrets.GetKeySecretAsync) .ToArray() .WaitAll(); List <X509Certificate2> result = new List <X509Certificate2>(); PemParsingCertificateReader rdr = new PemParsingCertificateReader(); foreach (KeySecret secret in pems.Where(ks => ks != null)) { X509Certificate2 cert = await rdr.GetCertificateAsync( value : secret.Value, password : new SecureString()); if (cert != null) { result.Add(cert); } } return(result); }