From: Menno Smits Date: Fri, 23 Jan 2015 10:35:55 +0000 (+1300) Subject: moved the internal _SSLConnection class further down the file X-Git-Tag: 1.0.0~1^2~57^2~28 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=91eea339e8326679f65ce2650127463a6e637b1f;p=imapclient.git moved the internal _SSLConnection class further down the file --- diff --git a/imapclient/tls.py b/imapclient/tls.py index ed1127c..895ad20 100644 --- a/imapclient/tls.py +++ b/imapclient/tls.py @@ -95,20 +95,8 @@ def get_default_context(cafile=None, capath=None, check_hostname=True): return context -class _SSLConnection(SSL.Connection): - """Wrapper for OpenSSL.SSL.Connection for socket compatibility.""" - - def shutdown(self, *args): - # Fix method signature incompatibility bewteen pyOpenSSL.SSL.Connection - # and socket.socket - SSL.Connection.shutdown(self) - - def makefile(self, mode='rb', *args, **kwargs): - # Support only arguments needed by imaplib - return _socketfileobj(self, mode) - - class IMAP4(imaplib.IMAP4): + def starttls(self, ssl_context=None): """Send a STARTTLS command and wrap the socket with TLS.""" name = 'STARTTLS' @@ -147,6 +135,19 @@ class IMAP4(imaplib.IMAP4): return self._untagged_response(type_, dat, name) +class _SSLConnection(SSL.Connection): + """Wrapper for OpenSSL.SSL.Connection for socket compatibility.""" + + def shutdown(self, *args): + # Fix method signature incompatibility bewteen pyOpenSSL.SSL.Connection + # and socket.socket + SSL.Connection.shutdown(self) + + def makefile(self, mode='rb', *args, **kwargs): + # Support only arguments needed by imaplib + return _socketfileobj(self, mode) + + # lifted from backports.ssl class _socketfileobj(object): """Custom file-like object to support socket.makefile for pyOpenSSL."""