[PYTHON-CRYPTO] [Fwd: Twisted+M2Crypto patch]

Heikki Toivonen heikki at OSAFOUNDATION.ORG
Fri Aug 13 20:43:09 CEST 2004


I wrote a patch to integrate M2Crypto into Twisted, modeling it after 
the existing SSL code in Twisted. Turns out the Twisted folks don't like 
their existing code, and therefore like my patch even less, meaning it 
won't be accepted into the Twisted codebase as is.

While they figure out what the architecture should be for plugging in 
other SSL implementations to Twisted I thought I'd share this patch here 
in case anyone found it useful. Also, there is one nasty hack in my 
patch and it would be really nice to hear if someone would be able to 
figure out a better way - look at abstract.py.

-------- Original Message --------
Subject: [Twisted-Python] Twisted+M2Crypto patch
Date: Wed, 11 Aug 2004 12:49:24 -0700

I've been working on integrating M2Crypto to Twisted. M2Crypto is a
Python wrapper for OpenSSL.

Twisted already integrates with PyOpenSSL, which is another Python
wrapper for OpenSSL. However, PyOpenSSL has been dormant for a couple of
years (although I have heard there might be a a rewrite in the making).
M2Crypto has been under continuous development, and wraps more of
OpenSSL. Additional point why I have been working on this is that
Chandler project started using M2Crypto before choosing to use Twisted,
and we are/will be relying on more and more M2Crypto functionality and
it does not make sense to have two OpenSSL wrappers in one application.

So, now I have a patch that let's you choose which of these OpenSSL
wrappers you want to use with Twisted.

By default PyOpenSSL will be selected. If you set 'useM2' attribute to
true on the SSL context factory (for example
twisted.internet.ssl.ClientContextFactory(useM2=True)), then M2Crypto
will be used.

I have tested using Twisted's echoclient_ssl.py/echoserv_ssl.py example
files (http://twistedmatrix.com/documents/current/examples/), as well as
imap and smtp using samples from here:
http://wiki.osafoundation.org/twiki/bin/view/Chandler/TwistedHome. I've
also read imap email using Chandler
(http://wiki.osafoundation.org/twiki/bin/view/Chandler/WebHome) with
this code. They rely on the patch that was submitted by OSAF's Brian
Kirsch earlier. I have tested on systems that have both M2Crypto and
PyOpenSSL installed, or only one but not the other. Test OSes have been
Windows XP and Debian (unstable).

There is one nasty hack in the patch which I have not yet ironed out:
the changes in abstract.py. If I take those out, I cannot connect to an
smtp server, and connection to a newly started server won't work the
first time. Any help in figuring this out would be appreciated.

Any review comments appreciated. And if you have any question, please
let me know.

-- 
   Heikki Toivonen

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: m2-patches
URL: <http://mail.python.org/pipermail/python-crypto/attachments/20040813/86c43827/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: file:///C|/DOCUME%7E1/HEIKKI/LOCALS%7E1/TEMP/nsmail-2.txt
URL: <http://mail.python.org/pipermail/python-crypto/attachments/20040813/86c43827/attachment.txt>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 249 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-crypto/attachments/20040813/86c43827/attachment.pgp>


More information about the python-crypto mailing list