def dumpasn1(self):
"""
Pretty print an ASN.1 DER object using cryptlib dumpasn1 tool.
Use a temporary file rather than popen4() because dumpasn1 uses
seek() when decoding ASN.1 content nested in OCTET STRING values.
"""
ret = None
fn = "dumpasn1.%d.tmp" % os.getpid()
try:
f = open(fn, "wb")
f.write(self.get_DER())
f.close()
p = subprocess.Popen(("dumpasn1", "-a", fn), stdout = subprocess.PIPE, stderr = subprocess.STDOUT)
ret = "\n".join(x for x in p.communicate()[0].splitlines() if x.startswith(" "))
except Exception, e:
ret = "[Could not run dumpasn1: %s]" % e
finally:
os.unlink(fn)
return ret
评论列表
文章目录