support for starttls

Nicolas Sebrecht nicolas.s-dev at
Mon Apr 11 17:01:21 BST 2011

On Mon, Apr 11, 2011 at 05:08:22PM +0200, Sebastian Spaeth wrote:
> On Mon, 11 Apr 2011 15:27:27 +0200, Johannes Stezenbach <js at> wrote:
> > connects to the server, then sets self.read_fd
> > and starts the self._reader thread, which uses select()
> > and read() on the socket.
> > 
> > Then starttls() calls ssl.wrap_socket() and updates self.read_fd,
> > but it seems the self._reader thread eats part of the SSL handshake.
> > 
> > I think to fix this starttls() needs to be done before
> > starting the self._reader thread.  (Or the thread needs to be killed
> > before ssl.wrap_socket() and restarted afterwards.)
> Great analysis. I concur that this is what must be happening. I
> forwarded your analysis to Piers the imaplib2 author. Let's see if he
> fixes it.

cc'ing him from this thread would have been great to let us know what's
going on upstream...

Nicolas Sebrecht

More information about the OfflineIMAP-project mailing list