Example #1
0
 def test_nid(self):
     assert m2.obj_ln2nid("commonName") == m2.obj_txt2nid(
         "2.5.4.3"), "ln2nid and txt2nid mismatch"
     assert m2.obj_ln2nid("CN") == 0, "ln2nid on sn"
     assert m2.obj_sn2nid("CN") == m2.obj_ln2nid(
         "commonName"), "ln2nid and sn2nid mismatch"
     assert m2.obj_sn2nid("CN") == m2.obj_obj2nid(m2.obj_txt2obj(
         "CN", 0)), "obj2nid"
     assert m2.obj_txt2nid("__unknown") == 0, "__unknown"
Example #2
0
def is_legacy_proxy(cert):
    for i in xrange(cert.get_ext_count()):
        ext = cert.get_ext_at(i)
        if ext.get_name().lower() == "proxycertinfo":
            return False
    for entry in cert.get_subject():
        # M2Crypto 0.16 не имеет нужного python api
        obj = m2.x509_name_entry_get_object(entry._ptr())
        objname = m2.obj_nid2sn(m2.obj_obj2nid(obj))
        val = entry.get_data().as_text()
        if objname == 'CN' and val in ('proxy', 'limited proxy'):
            return True
    return False
Example #3
0
 def test_nid(self):
     self.assertEqual(m2.obj_ln2nid("commonName"),
                      m2.obj_txt2nid("2.5.4.3"),
                      "ln2nid and txt2nid mismatch")
     self.assertEqual(m2.obj_ln2nid("CN"),
                      0, "ln2nid on sn")
     self.assertEqual(m2.obj_sn2nid("CN"),
                      m2.obj_ln2nid("commonName"),
                      "ln2nid and sn2nid mismatch")
     self.assertEqual(m2.obj_sn2nid("CN"),
                      m2.obj_obj2nid(m2.obj_txt2obj("CN", 0)), "obj2nid")
     self.assertEqual(m2.obj_txt2nid("__unknown"),
                      0, "__unknown")
Example #4
0
def is_legacy_proxy(cert):
    for i in xrange(cert.get_ext_count()):
        ext = cert.get_ext_at(i)
        if ext.get_name().lower() == "proxycertinfo":
            return False
    for entry in cert.get_subject():
        # M2Crypto 0.16 не имеет нужного python api
        obj = m2.x509_name_entry_get_object(entry._ptr())
        objname = m2.obj_nid2sn(m2.obj_obj2nid(obj))
        val = entry.get_data().as_text()
        if objname == 'CN' and val in ('proxy', 'limited proxy'):
            return True
    return False
Example #5
0
def is_legacy_proxy(cert):
    """Check if certificate is a legacy proxy certificate"""
    for i in xrange(cert.get_ext_count()):
        ext = cert.get_ext_at(i)
        if ext.get_name().lower() == "proxycertinfo":
            return False
    for entry in cert.get_subject():
        # M2Crypto 0.16 does not implement the corresponding python api :(
        obj = m2.x509_name_entry_get_object(entry._ptr())
        objname = m2.obj_nid2sn(m2.obj_obj2nid(obj))
        val = entry.get_data().as_text()
        if objname == 'CN' and val in ('proxy', 'limited proxy'):
            return True
    return False
Example #6
0
 def test_nid(self):
     assert m2.obj_ln2nid("commonName") == m2.obj_txt2nid("2.5.4.3"), "ln2nid and txt2nid mismatch"
     assert m2.obj_ln2nid("CN") == 0, "ln2nid on sn"
     assert m2.obj_sn2nid("CN") == m2.obj_ln2nid("commonName"), "ln2nid and sn2nid mismatch"
     assert m2.obj_sn2nid("CN") == m2.obj_obj2nid(m2.obj_txt2obj("CN", 0)), "obj2nid"
     assert m2.obj_txt2nid("__unknown") == 0, "__unknown"
Example #7
0
def asn1_object_get_sn(self):
    return m2.obj_nid2sn(m2.obj_obj2nid(self._ptr()))