[Twisted-Python] Twisted+M2Crypto patch

Heikki Toivonen heikki at osafoundation.org
Wed Aug 11 13:49:24 MDT 2004

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: </pipermail/twisted-python/attachments/20040811/a0963b81/attachment.ksh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 249 bytes
Desc: OpenPGP digital signature
URL: </pipermail/twisted-python/attachments/20040811/a0963b81/attachment.sig>

More information about the Twisted-Python mailing list