From b54dc68991117ffd6d31826f86e4744389efb4dd Mon Sep 17 00:00:00 2001 From: Alexandre Dulaunoy Date: Fri, 24 Apr 2015 08:08:27 +0200 Subject: [PATCH] Handle OpenSSL errors --- bin/x509/pcap-sslcert.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bin/x509/pcap-sslcert.py b/bin/x509/pcap-sslcert.py index 6fbc4bc..a48fb97 100644 --- a/bin/x509/pcap-sslcert.py +++ b/bin/x509/pcap-sslcert.py @@ -55,7 +55,11 @@ for l in fileinput.input(args.r): dercert = binascii.unhexlify(a) except TypeError: continue - x509 = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_ASN1, dercert) + try: + x509 = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_ASN1, dercert) + except OpenSSL.crypto.Error: + continue + c['fp'] = x509.digest('sha1').replace(':','').lower() if args.v: print "("+c['session']+") "+c['srcip']+"<->"+c['dstip']+":"+c['dstport']