예제 #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))
예제 #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)
예제 #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())
예제 #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]
예제 #5
0
 def test_construct_invalid_type(self):
     with self.assertRaises(errors.X509Error):
         extension.construct_extension("foobar")
예제 #6
0
 def get_extensions(self):
     extensions = self._get_extensions()
     return [extension.construct_extension(e) for e in extensions]
예제 #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]
예제 #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
     ]