[Python-Dev] ssl module integration with asyncore (original) (raw)

Giampaolo Rodola' gnewsg at gmail.com
Thu Nov 29 02:52:31 CET 2007


On 29 Nov, 00:26, Bill Janssen <jans... at parc.com> wrote:

> I tried to write a simple asyncore-based server code, then I used a > simple client to establish a connection with it. > Once the client is connected server raises the following exception:

I think this is a bug. Thanks!

You're welcome.

The issue is that the internal call to dohandshake() doesn't handle non-blocking sockets properly.

You can work around the bug like this: --- snippet --- import asyncore, asynchat, socket, ssl, select class Handler(asyncore.dispatcher): def init(self, conn): asyncore.dispatcher.init(self, conn) self.socket = ssl.wrapsocket(conn, serverside=True, certfile='keycert.pem', dohandshakeonconnect=False) while True: try: self.socket.dohandshake() break except ssl.SSLError, err: if err.args[0] == ssl.SSLERRORWANTREAD: select.select([self.socket], [], []) elif err.args[0] == ssl.SSLERRORWANTWRITE: select.select([], [self.socket], []) else: raise self.send('hi there') --- /snippet --- Bill

It does raise the same exception. Are there plans for fixing this? Using that kind of workaround is not acceptable in any case (select module shouldn't even get imported when using asyncore). Moreover I think we need at least a minimal test suite to make sure that non-blocking sockets work properly. I'm not experienced with ssl module but I know asyncore/asynchat quite good. If you need some help I could propose myself for writing a minimal test suite for asyncore integration with ssl module when the bocking issues will be fixed.



More information about the Python-Dev mailing list