From 2ee5e3c6240721120146d6d81c70e1b900029ee0 Mon Sep 17 00:00:00 2001 From: Joshua Tauberer Date: Sat, 4 Jul 2015 20:09:46 +0000 Subject: parse SAN otherNames into OtherName instances rather than raising an exception Test added. --- tests/test_x509_ext.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'tests/test_x509_ext.py') diff --git a/tests/test_x509_ext.py b/tests/test_x509_ext.py index d15d6669..06adaa37 100644 --- a/tests/test_x509_ext.py +++ b/tests/test_x509_ext.py @@ -1578,6 +1578,30 @@ class TestRSASubjectAlternativeNameExtension(object): assert 'Invalid rfc822name value' in str(exc.value) + def test_other_name(self, backend): + cert = _load_cert( + os.path.join( + "x509", "custom", "san_other_name.pem" + ), + x509.load_pem_x509_certificate, + backend + ) + + ext = cert.extensions.get_extension_for_oid( + x509.OID_SUBJECT_ALTERNATIVE_NAME + ) + assert ext is not None + assert ext.critical is False + + assert len(ext.value) == 1 + assert list(ext.value)[0] == \ + x509.OtherName( + x509.ObjectIdentifier("1.2.3.4"), + b'\x16\x0bHello World') + + othernames = ext.value.get_values_for_type(x509.OtherName) + assert othernames == [b'\x16\x0bHello World'] + @pytest.mark.requires_backend_interface(interface=RSABackend) @pytest.mark.requires_backend_interface(interface=X509Backend) -- cgit v1.2.3