From b1643dab6482a12d63800d5463f92efc0f8edcdf Mon Sep 17 00:00:00 2001 From: Alexandre Dulaunoy Date: Sun, 1 Feb 2015 14:03:16 +0100 Subject: [PATCH] Verbose option added (-v) to show issuer CN and subject CN --- bin/x509/pcap-sslcert.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bin/x509/pcap-sslcert.py b/bin/x509/pcap-sslcert.py index 6f9d7a8..c05ae42 100644 --- a/bin/x509/pcap-sslcert.py +++ b/bin/x509/pcap-sslcert.py @@ -14,6 +14,7 @@ import OpenSSL import argparse argParser = argparse.ArgumentParser(description='Extract certificate to PEM format from an ssldump output') +argParser.add_argument('-v', default=False, action='store_true', help='Verbose output') argParser.add_argument('-r', default='-', help='Read from a file, default is stdin') args = argParser.parse_args() @@ -39,6 +40,9 @@ for l in fileinput.input(args.r): dercert = binascii.unhexlify(a) x509 = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_ASN1, dercert) fp = x509.digest('sha1').replace(':','').lower() + if args.v: + print "Issuer: " + x509.get_issuer().CN + print "CN: " + x509.get_subject().CN print OpenSSL.crypto.dump_certificate(OpenSSL.crypto.FILETYPE_PEM, x509) certstring = "" y = ""