tags:

views:

97

answers:

2

I am tasked with migrating a server's networking from plain sockets to SSL in python 2.5, and I've run into a snag. It seems that just about no SSL library out there fully implements the socket interface, so the code we currently have can't be straight migrated.

Specifically, I can't seem to find a library that supports the 'setblocking' method (most of these are wrappers, so would it be terrible to just address the wrapped socket directly?) and most don't seem to treat the wrapped socket as a file-like device, so the crucial 'select' method won't work (again, could I run select on the wrapped socket?).

(read, write, error) = select([socket], [socket], [], 0.2)

I have tried tlslite and M2Crypto so far, but neither seem to work transparently as sockets.

Any ideas would be appreciated.

A: 

pyOpenSSL seems to support setblocking().

Ignacio Vazquez-Abrams
I have considered pyOpenSSL, but I'm a bit uncertain about it, as it's no longer maintained. Then again, I suppose most libraries are unmaintained as SSL has decent support in more recent versions of Python.
directedition
+2  A: 

How about this backport of Python 2.6's ssl module to Python 2.3+? It provides the same functionality described here, which appears to mean that it takes a normal socket.socket and wraps it in an SSL context.

Will McCutchen