diff options
author | Christian Heimes <christian@cheimes.de> | 2013-12-02 19:01:29 (GMT) |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2013-12-02 19:01:29 (GMT) |
commit | 48aae57996c89a5601534320fdd078da978fb7bb (patch) | |
tree | 77c04c61c848c35eceeaa0962e5d185fbc8a8833 /Lib/imaplib.py | |
parent | 0c924b83eefead8c111f66452b0681a5c7485a5c (diff) | |
download | cpython-48aae57996c89a5601534320fdd078da978fb7bb.zip cpython-48aae57996c89a5601534320fdd078da978fb7bb.tar.gz cpython-48aae57996c89a5601534320fdd078da978fb7bb.tar.bz2 |
Issue #19782: imaplib now supports SSLContext.check_hostname and server name
indication for TLS/SSL connections.
Diffstat (limited to 'Lib/imaplib.py')
-rw-r--r-- | Lib/imaplib.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/imaplib.py b/Lib/imaplib.py index dabf161..ade2f9c 100644 --- a/Lib/imaplib.py +++ b/Lib/imaplib.py @@ -745,7 +745,9 @@ class IMAP4: ssl_context = ssl._create_stdlib_context() typ, dat = self._simple_command(name) if typ == 'OK': - self.sock = ssl_context.wrap_socket(self.sock) + server_hostname = self.host if ssl.HAS_SNI else None + self.sock = ssl_context.wrap_socket(self.sock, + server_hostname=server_hostname) self.file = self.sock.makefile('rb') self._tls_established = True self._get_capabilities() @@ -1216,7 +1218,9 @@ if HAVE_SSL: def _create_socket(self): sock = IMAP4._create_socket(self) - return self.ssl_context.wrap_socket(sock) + server_hostname = self.host if ssl.HAS_SNI else None + return self.ssl_context.wrap_socket(sock, + server_hostname=server_hostname) def open(self, host='', port=IMAP4_SSL_PORT): """Setup connection to remote server on "host:port". |