[Twisted-Python] M2Crypto+Twisted, part 2

Jp Calderone exarkun at divmod.com
Wed Dec 8 10:04:46 EST 2004

On Tue, 07 Dec 2004 17:46:52 -0800, Heikki Toivonen <heikki at osafoundation.org> wrote:
>A while back I integrated M2Crypto into Twisted, but the architecture 
> was not deemed good then (it was adding more of the SSL cruft in tcp.py 
> etc.).
> James Knight pointed me to TLS Lite, which had achieved similar 
> functionality by using ProtocolWrapper and WrappingFactory and all the 
> code was outside of Twisted. (Thanks James!)
> I've now got an implementation of M2Crypto + Twisted integration using 
> the TLS Lite approach - no changes in Twisted required. (Client only for 
> now and not yet fully cleaned up, but all the important pieces should be 
> there.)
> However, I've run into some problems and I am not sure if they are bugs 
> in Twisted or if I am using these interfaces wrong. Maybe you can help.
> The most interesting piece of the code is my TLSProtocolWrapper that 
> inherits from ProtocolWrapper. See 
> http://lxr.osafoundation.org/source/internal/m2crypto/M2Crypto/SSL/TwistedProtocolWrapper.py
> Now, this seems to works perfectly with the echoclient samples when the 
> SSL connection has no errors.
> When there is an error in the SSL connection, and I call 
> connectionLost(), I end up with a traceback that feels like it might be 
> a Twisted bug. Or if I am not allowed to call that, how do I signal that 
> I want to break the connection? Here's the traceback:

  You should call proto.transport.loseConnection() instead of proto.connectionLost().  The former indicates to the reactor that the connection should be dropped, the latter is a callback that the reactor invokes to tell you that the connection has been dropped.


More information about the Twisted-Python mailing list