public void ParseCertificatesResponseInvalidCertificateShouldThrow() { ServerCertificateResponse cert = new ServerCertificateResponse() { Certificate = "InvalidCert" }; Assert.Throws <InvalidOperationException>(() => CertificateHelper.ParseCertificateResponse(cert)); }
public void ParseCertificatesResponseInvalidCertificateShouldThrow() { var response = new CertificateResponse() { Certificate = "InvalidCert", }; Assert.Throws <InvalidOperationException>(() => CertificateHelper.ParseCertificateResponse(response)); }
public void ParseCertificatesResponseInvalidKeyShouldThrow() { var response = new ServerCertificateResponse() { Certificate = TestCertificateHelper.CertificatePem, PrivateKey = "InvalidKey" }; Assert.Throws <InvalidOperationException>(() => CertificateHelper.ParseCertificateResponse(response)); }
public void ParseCertificatesResponseInvalidKeyShouldThrow() { var response = new CertificateResponse() { Certificate = TestCertificateHelper.CertificatePem, Expiration = DateTime.UtcNow.AddDays(1), PrivateKey = new PrivateKey() { Bytes = "InvalidKey" } }; Assert.Throws <InvalidOperationException>(() => CertificateHelper.ParseCertificateResponse(response)); }
public void ParseCertificatesResponseShouldReturnCert() { TestCertificateHelper.GenerateSelfSignedCert("top secret").Export(X509ContentType.Cert); var response = new ServerCertificateResponse() { Certificate = $"{TestCertificateHelper.CertificatePem}\n{TestCertificateHelper.CertificatePem}", PrivateKey = TestCertificateHelper.PrivateKeyPem }; (X509Certificate2 cert, IEnumerable <X509Certificate2> chain) = CertificateHelper.ParseCertificateResponse(response); var expected = new X509Certificate2(Encoding.UTF8.GetBytes(TestCertificateHelper.CertificatePem)); Assert.Equal(expected, cert); Assert.True(cert.HasPrivateKey); Assert.Single(chain); Assert.Equal(expected, chain.First()); }
public void ParseCertificatesResponseShouldReturnCert() { TestCertificateHelper.GenerateSelfSignedCert("top secret").Export(X509ContentType.Cert); var response = new CertificateResponse() { Certificate = $"{TestCertificateHelper.CertificatePem}\n{TestCertificateHelper.CertificatePem}", Expiration = DateTime.UtcNow.AddDays(1), PrivateKey = new PrivateKey() { Bytes = TestCertificateHelper.PrivateKeyPem } }; (X509Certificate2 cert, IEnumerable <X509Certificate2> chain) = CertificateHelper.ParseCertificateResponse(response); var expected = new X509Certificate2(Encoding.UTF8.GetBytes(TestCertificateHelper.CertificatePem)); Assert.Equal(expected, cert); Assert.True(cert.HasPrivateKey); Assert.Equal(chain.Count(), 1); Assert.Equal(expected, chain.First()); }