Esempio n. 1
0
 def test_serialise(self):
     asn1 = rfc5280.Extension()
     asn1['extnID'] = univ.ObjectIdentifier('1.2.3.4')
     asn1['critical'] = False
     asn1['extnValue'] = "foobar"
     ext = extension.construct_extension(asn1)
     self.assertEqual(ext.as_der(), encoder.encode(asn1))
Esempio n. 2
0
 def test_construct(self):
     asn1 = rfc5280.Extension()
     asn1['extnID'] = univ.ObjectIdentifier('1.2.3.4')
     asn1['critical'] = False
     asn1['extnValue'] = "foobar"
     ext = extension.construct_extension(asn1)
     self.assertIsInstance(ext, extension.X509Extension)
Esempio n. 3
0
 def test_critical(self):
     asn1 = rfc5280.Extension()
     asn1['extnID'] = univ.ObjectIdentifier('1.2.3.4')
     asn1['critical'] = False
     asn1['extnValue'] = "foobar"
     ext = extension.construct_extension(asn1)
     self.assertFalse(ext.get_critical())
     ext.set_critical(True)
     self.assertTrue(ext.get_critical())
Esempio n. 4
0
    def get_extensions(self, ext_type=None):
        """Get the list of all X509 V3 Extensions on this CSR

        :return: a list of X509Extension objects
        """
        ext_attrs = [a for a in self.get_attributes()
                     if a['attrType'] == OID_extensionRequest]
        if len(ext_attrs) == 0:
            return []
        else:
            exts_der = ext_attrs[0]['attrValues'][0].asOctets()
            exts = decoder.decode(exts_der, asn1Spec=rfc5280.Extensions())[0]
            return [extension.construct_extension(e) for e in exts
                    if ext_type is None or e['extnID'] == ext_type._oid]
Esempio n. 5
0
 def test_construct_invalid_type(self):
     with self.assertRaises(errors.X509Error):
         extension.construct_extension("foobar")
Esempio n. 6
0
 def get_extensions(self):
     extensions = self._get_extensions()
     return [extension.construct_extension(e) for e in extensions]
Esempio n. 7
0
 def get_extensions(self, ext_type=None):
     extensions = self._get_extensions()
     return [extension.construct_extension(e) for e in extensions
             if ext_type is None or e['extnID'] == ext_type._oid]
Esempio n. 8
0
 def get_extensions(self, ext_type=None):
     extensions = self._get_extensions()
     return [
         extension.construct_extension(e) for e in extensions
         if ext_type is None or e['extnID'] == ext_type._oid
     ]