Example #1
0
        public void ParseOpenSSL_SAN()
        {
            // Verify an [OpenSSL] dump of a SAN certificate.

            const string dump =
                @"Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number:
            f7:c3:3b:6e:ed:61:a3:69:5c:1a:61:e7:7e:7d:34:9f
    Signature Algorithm: sha256WithRSAEncryption
        Issuer: C=GB, ST=Greater Manchester, L=Salford, O=COMODO CA Limited, CN=COMODO RSA Domain Validation Secure Server CA
        Validity
            Not Before: Oct 16 00:00:00 2016 GMT
            Not After : Oct 16 23:59:59 2017 GMT
        Subject: OU=Domain Control Validated, OU=PositiveSSL Wildcard, CN=*.neontest.com
        Subject Public Key Info:
            Public Key Algorithm: rsaEncryption
                Public-Key: (2048 bit)
                Modulus:
                    00:e3:40:b1:8a:4f:ce:50:71:5d:00:8f:e7:b2:f0:
                    52:22:2d:7b:f4:97:01:e6:d5:cf:37:2f:62:a8:1b:
                    af:87:ca:26:d6:9a:83:f9:21:25:2d:4e:f8:f7:85:
                    7b:65:06:1b:17:de:53:e7:4f:77:b1:ac:71:d5:49:
                    7e:9b:f8:42:48:3a:83:af:3b:03:87:c8:c6:d1:2e:
                    f8:cb:fa:5b:d5:9f:f3:68:b6:c4:87:82:9f:9c:e3:
                    b7:c3:7b:71:cb:bc:f9:00:1b:0d:7e:b2:ae:7a:50:
                    8f:cb:0c:01:e5:6b:72:a3:dc:08:a1:f3:53:88:84:
                    92:5c:3b:88:28:20:de:39:22:ac:6e:53:99:cf:43:
                    dd:20:ee:2e:1c:02:f4:42:13:84:75:03:17:0c:bf:
                    46:59:44:70:ac:fa:3e:2d:d9:ca:47:6e:a8:a2:13:
                    72:5e:d5:fd:4b:60:99:27:01:35:a3:1a:70:9a:9d:
                    48:bb:89:14:0b:ed:a7:de:90:90:25:db:31:81:33:
                    96:c5:7f:7a:b6:61:db:22:8e:93:5d:a0:e9:02:a9:
                    f3:05:72:3f:79:ed:fa:69:c3:a9:e5:ef:5c:7f:db:
                    36:aa:df:b6:76:16:fc:b6:f2:0b:b8:cb:21:8e:e6:
                    00:85:35:d8:7e:01:c1:fb:78:b5:ba:4e:91:4e:dd:
                    9f:4f
                Exponent: 65537 (0x10001)
        X509v3 extensions:
            X509v3 Authority Key Identifier: 
                keyid:90:AF:6A:3A:94:5A:0B:D8:90:EA:12:56:73:DF:43:B4:3A:28:DA:E7

            X509v3 Subject Key Identifier: 
                70:AC:36:1F:8E:34:33:4A:41:95:7B:D5:EF:3D:D8:98:6C:D4:C8:D9
            X509v3 Key Usage: critical
                Digital Signature, Key Encipherment
            X509v3 Basic Constraints: critical
                CA:FALSE
            X509v3 Extended Key Usage: 
                TLS Web Server Authentication, TLS Web Client Authentication
            X509v3 Certificate Policies: 
                Policy: 1.3.6.1.4.1.6449.1.2.2.7
                  CPS: https://secure.comodo.com/CPS
                Policy: 2.23.140.1.2.1

            X509v3 CRL Distribution Points: 

                Full Name:
                  URI:http://crl.comodoca.com/COMODORSADomainValidationSecureServerCA.crl

            Authority Information Access: 
                CA Issuers - URI:http://crt.comodoca.com/COMODORSADomainValidationSecureServerCA.crt
                OCSP - URI:http://ocsp.comodoca.com

            X509v3 Subject Alternative Name: 
                DNS:*.neontest.com, DNS:neontest.com
    Signature Algorithm: sha256WithRSAEncryption
         49:a5:35:66:4b:e2:2d:45:c4:6b:6f:91:a0:1e:bc:52:d5:08:
         a6:88:9d:e4:67:3e:77:ca:90:3b:b6:fc:b4:7c:2b:bf:96:d8:
         9c:25:14:67:4f:bd:b0:f8:15:e0:57:78:ae:05:1d:4a:ec:68:
         83:a5:f7:bb:63:a2:4a:cd:82:50:ad:60:92:45:e0:0f:f0:20:
         d0:bf:a8:f2:ee:20:dd:d6:d2:54:04:b8:4b:97:2f:d2:f0:11:
         29:63:27:4b:ad:4b:0c:06:1d:93:bb:02:e9:86:0a:51:42:b4:
         56:0f:c6:56:ac:74:25:45:45:d5:3c:ee:57:21:ef:cf:a8:7e:
         d7:78:1e:f5:22:74:d9:b4:54:97:ed:8a:5b:70:94:6b:a9:9c:
         c3:54:09:10:2d:20:21:7d:98:3b:8a:c6:86:df:d5:e3:0a:6b:
         ee:89:f1:44:02:f2:3b:cd:79:97:04:ea:4c:77:19:c5:22:66:
         dd:57:07:97:1a:c3:83:c9:84:34:0f:d9:13:9f:78:b5:29:46:
         0f:d8:0c:bf:8b:10:25:63:f2:ed:7e:47:b8:a9:95:a7:c8:cd:
         3d:42:7a:c6:69:0c:1c:14:92:57:af:59:3f:75:85:4a:14:6a:
         20:b0:52:9c:4e:c6:03:87:9c:b5:c5:59:48:be:3c:c7:38:5e:
         a2:72:85:1b
-----BEGIN CERTIFICATE-----
MIIFUjCCBDqgAwIBAgIRAPfDO27tYaNpXBph5359NJ8wDQYJKoZIhvcNAQELBQAw
gZAxCzAJBgNVBAYTAkdCMRswGQYDVQQIExJHcmVhdGVyIE1hbmNoZXN0ZXIxEDAO
BgNVBAcTB1NhbGZvcmQxGjAYBgNVBAoTEUNPTU9ETyBDQSBMaW1pdGVkMTYwNAYD
VQQDEy1DT01PRE8gUlNBIERvbWFpbiBWYWxpZGF0aW9uIFNlY3VyZSBTZXJ2ZXIg
Q0EwHhcNMTYxMDE2MDAwMDAwWhcNMTcxMDE2MjM1OTU5WjBbMSEwHwYDVQQLExhE
b21haW4gQ29udHJvbCBWYWxpZGF0ZWQxHTAbBgNVBAsTFFBvc2l0aXZlU1NMIFdp
bGRjYXJkMRcwFQYDVQQDDA4qLm5lb250ZXN0LmNvbTCCASIwDQYJKoZIhvcNAQEB
BQADggEPADCCAQoCggEBAONAsYpPzlBxXQCP57LwUiIte/SXAebVzzcvYqgbr4fK
Jtaag/khJS1O+PeFe2UGGxfeU+dPd7GscdVJfpv4Qkg6g687A4fIxtEu+Mv6W9Wf
82i2xIeCn5zjt8N7ccu8+QAbDX6yrnpQj8sMAeVrcqPcCKHzU4iEklw7iCgg3jki
rG5Tmc9D3SDuLhwC9EIThHUDFwy/RllEcKz6Pi3ZykduqKITcl7V/UtgmScBNaMa
cJqdSLuJFAvtp96Qk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UJ6xmkMHBSSV69ZP3WFShRq
ILBSnE7GA4ectcVZSL48xzheonKFGw==
-----END CERTIFICATE-----
";

            var cert = new TlsCertificate();

            cert.ParseOpenSsl(dump);

            Assert.Equal(new DateTime(2016, 10, 16, 00, 00, 00, DateTimeKind.Utc), cert.ValidFrom);
            Assert.Equal(new DateTime(2017, 10, 16, 23, 59, 59, DateTimeKind.Utc), cert.ValidUntil);
            Assert.Equal(new string[] { "*.neontest.com", "neontest.com" }, cert.Hosts);
        }