[Tutor] pyopenssl - extracting email certificates information

Paul Tader ptader at linuxscope.com
Sun Jul 13 16:18:40 CEST 2008

Given a raw email I've been able to extract the cryptographic signature
(in encoded or decoded format) into a string.  I would like to like to use
the pyopenssl crypto module
(http://pyopenssl.sourceforge.net/pyOpenSSL.html/openssl.html) to further
extract things like the Signing Authority and the DN subject. So far the
"object orientating" part of python is something I haven't fully grasped
yet so I don't know how to load my certificate string into the pyopenssl
objects so that I can apply its methods.

It's not pretty, but what I have so far...

import os
import sys
import re
import base64

f = open("test.mail", "r")
contents = f.read()
r1 = re.compile('MI.{70}')
r2 = re.compile('AAAAAAAA')
s1 = r1.search(contents)
a = int(s1.start())
s2 = r2.search(contents, a)
b = int(s2.end())
hash = contents[a:b]
encoded = "begin-base64 644 signature.out\n" + hash + "\n===="
decoded = base64.decodestring(encoded)


More information about the Tutor mailing list