Beispiel #1
0
        public void ParseECCCertificateAndPkcs8KeyShouldReturnCertAndKey()
        {
            (X509Certificate2 cert, IEnumerable <X509Certificate2> chain) = CertificateHelper.ParseCertificateAndKey(TestCertificateHelper.ECCCertificatePem, TestCertificateHelper.ECCPrivateKeyPemPkcs8);

            Assert.True(cert.HasPrivateKey);
            Assert.Empty(chain);
        }
Beispiel #2
0
        public void ParseECCCertificateAndKeyShouldReturnCertAndKey()
        {
            (X509Certificate2 cert, IEnumerable <X509Certificate2> chain) = CertificateHelper.ParseCertificateAndKey(TestCertificateHelper.ECCCertificatePem, TestCertificateHelper.ECCPrivateKeyPem);

            var expected = new X509Certificate2(Encoding.UTF8.GetBytes(TestCertificateHelper.CertificatePem));

            Assert.True(cert.HasPrivateKey);
            Assert.Empty(chain);
        }
Beispiel #3
0
        public void ParseRSACertificateAndKeyShouldReturnCertAndKey()
        {
            TestCertificateHelper.GenerateSelfSignedCert("top secret").Export(X509ContentType.Cert);
            (X509Certificate2 cert, IEnumerable <X509Certificate2> chain) = CertificateHelper.ParseCertificateAndKey(TestCertificateHelper.CertificatePem, TestCertificateHelper.PrivateKeyPem);

            var expected = new X509Certificate2(Encoding.UTF8.GetBytes(TestCertificateHelper.CertificatePem));

            Assert.Equal(expected, cert);
            Assert.True(cert.HasPrivateKey);
            Assert.Empty(chain);
        }
Beispiel #4
0
        public void ParseMultipleCertificateAndKeyShouldReturnCertAndKey()
        {
            TestCertificateHelper.GenerateSelfSignedCert("top secret").Export(X509ContentType.Cert);
            string certificate = $"{TestCertificateHelper.CertificatePem}\n{TestCertificateHelper.CertificatePem}";

            (X509Certificate2 cert, IEnumerable <X509Certificate2> chain) = CertificateHelper.ParseCertificateAndKey(certificate, TestCertificateHelper.PrivateKeyPemPkcs8);

            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());
        }