Exemplo 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))
Exemplo 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)
Exemplo n.º 3
0
 def test_unknown_extension_str(self):
     asn1 = rfc5280.Extension()
     asn1['extnID'] = univ.ObjectIdentifier('1.2.3.4')
     asn1['critical'] = False
     asn1['extnValue'] = "foobar"
     ext = extension.X509Extension(asn1)
     self.assertEqual("1.2.3.4: <unknown>", str(ext))
Exemplo n.º 4
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())
Exemplo n.º 5
0
 def __init__(self, ext=None):
     if ext is None:
         if self.spec is None:
             raise errors.X509Error("cannot create generic extension")
         self._ext = rfc5280.Extension()
         self._ext['extnID'] = self._oid
         self._set_value(self._get_default_value())
     else:
         if not isinstance(ext, rfc5280.Extension):
             raise errors.X509Error("extension has incorrect type")
         self._ext = ext