[Python-Dev] ssl - how to switch back to a plain text socket?

Bill Janssen janssen at parc.com
Wed Feb 20 17:39:47 CET 2008


> > I suggest using socket.dup(sslsock) to simply create a non-encrypted
> > copy of the socket, and switch to using that copy.  There's no way to
> > "unwrap" an SSLSocket.
> 
> It does not seem to work:
> 
>  File "C:\python26\lib\ssl.py", line 115, in read
>    return self._sslobj.read(len)
> ssl.SSLError: [Errno 1] _ssl.c:1276: error:1408F10B:SSL
> routines:SSL3_GET_RECORD:wrong version number

You're still reading from the _sslobj.  Don't do that.  Read from the
non-encrypted copy, instead.

Though I don't believe you'll be able to implement the CCC command
this way; the spec specifically says to do the TLS shutdown, and
there's no way to emulate it.

> I'm not sure, I've seen more than one library and server supporting
> the CCC command.
> For example proftpd and tnftpd servers support it.

But does anyone use it?

Bill


More information about the Python-Dev mailing list