Some good news: I finally figured out how to modify asyncore to make
it properly handle the non-blocking ssl-handshake.
I provided a patch for test_ssl.py in issue 3899.
Bill, could you please review it?
--- Giampaolo
http://code.google.com/p/pyftpdlib/
On 18 Set, 00:49, "Giampaolo Rodola'"
Ok, here's some news, in case they can be of some interest. I managed to write an asyncore disptacher which seems to work. I used my test suite against it and 70 tests passed and 2 failed. The tests failed because at a certain point a call to do_handhsake results in an EOF exception, which is very strange since it is supposed to raise SSL_ERROR_WANT_READ or SSL_ERROR_WANT_WRITE only. I'll keep you updated in case I have some news.
--- Exception ---
File "C:\python26\lib\ssl.py", line 293, in do_handshake self._sslobj.do_handshake() SSLError: [Errno 8] _ssl.c:480: EOF occurred in violation of protocol
--- SSL dispatcher ----
class SSLConnection(asyncore.dispatcher):
def __init__(self): self.ssl_handshake_pending = False
def do_ssl_handshake(self): try: self.socket.do_handshake() except ssl.SSLError, err: if err.args[0] == ssl.SSL_ERROR_WANT_READ: self.ssl_handshake_pending = 'read' elif err.args[0] == ssl.SSL_ERROR_WANT_WRITE: self.ssl_handshake_pending = 'write' else: raise else: self.ssl_handshake_pending = False
def handle_read_event(self): if self.ssl_handshake_pending == 'read': self.do_ssl_handshake() ## if not self.ssl_handshake_pending: ## asyncore.dispatcher.handle_read_event(self) else: asyncore.dispatcher.handle_read_event(self)
def handle_write_event(self): if self.ssl_handshake_pending == 'write': self.do_ssl_handshake() ## if not self.ssl_handshake_pending: ## asyncore.dispatcher.handle_write_event(self) else: asyncore.dispatcher.handle_write_event(self)
--- Giampaolohttp://code.google.com/p/pyftpdlib/ _______________________________________________ Python-Dev mailing list Python-...@python.orghttp://mail.python.org/mailman/listinfo/python-dev Unsubscribe:http://mail.python.org/mailman/options/python-dev/python-dev2-garchiv...