diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2015-06-28 10:14:55 -0400 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2015-06-28 10:14:55 -0400 |
commit | d3e84164d9932782beebfb997615bca6f6d30a8b (patch) | |
tree | 7c89e2894951d76e4e61a09df0948085729749ef /tests/test_x509.py | |
parent | 5432f818890a67a8c6c53ebdea47fd9dd7ec1ae9 (diff) | |
download | cryptography-d3e84164d9932782beebfb997615bca6f6d30a8b.tar.gz cryptography-d3e84164d9932782beebfb997615bca6f6d30a8b.tar.bz2 cryptography-d3e84164d9932782beebfb997615bca6f6d30a8b.zip |
Initial code to encode SANs
Diffstat (limited to 'tests/test_x509.py')
-rw-r--r-- | tests/test_x509.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/test_x509.py b/tests/test_x509.py index df315cc3..64a59237 100644 --- a/tests/test_x509.py +++ b/tests/test_x509.py @@ -884,6 +884,30 @@ class TestCertificateSigningRequestBuilder(object): ]) ) + def test_subject_alt_names(self, backend): + private_key = RSA_KEY_2048.private_key(backend) + + csr = x509.CertificateSigningRequestBuilder().subject_name( + x509.Name([ + x509.NameAttribute(x509.OID_COMMON_NAME, u"SAN"), + ]) + ).add_extension( + x509.SubjectAlternativeName([ + x509.DNSName(u"google.com"), + ]), + critical=False, + ).sign(private_key, hashes.SHA256(), backend) + + assert len(csr.extensions) == 1 + ext = csr.extensions.get_extension_for_oid( + x509.OID_SUBJECT_ALTERNATIVE_NAME + ) + assert not ext.critical + assert ext.oid == x509.OID_SUBJECT_ALTERNATIVE_NAME + assert list(ext.value) == [ + x509.DNSName(u"google.com"), + ] + @pytest.mark.requires_backend_interface(interface=DSABackend) @pytest.mark.requires_backend_interface(interface=X509Backend) |