def __init__(self, value): """ Object constructor. Accepts string, integer, or another Oid object. Integer should be OpenSSL numeric identifier (nid) as returned by some libcrypto function or extracted from some libcrypto structure """ if isinstance(value, unicode): value = value.encode('ascii') if isinstance(value, str): self.nid = libcrypto.OBJ_txt2nid(value) if self.nid == 0: raise ValueError("Cannot find object %s in the database" % value) elif isinstance(value, (int, long)): short = libcrypto.OBJ_nid2sn(value) if short is None: raise ValueError("No such nid %d in the database" % value) self.nid = value elif isinstance(value, Oid): self.nid = value.nid else: raise TypeError("Cannot convert this type to object identifier")
def shortname(self): " Returns short name if any " return libcrypto.OBJ_nid2sn(self.nid)
def shortname(self): " Returns short name if any " return libcrypto.OBJ_nid2sn(self.nid).decode('utf-8')