summaryrefslogtreecommitdiffstats
path: root/Lib/poplib.py
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2013-12-02 19:10:50 (GMT)
committerChristian Heimes <christian@cheimes.de>2013-12-02 19:10:50 (GMT)
commit1bc7068d7fde0eaf2155240f629bcf80280daff6 (patch)
treead4f3a6cb110ffca75e33511eabaed1d5854ef25 /Lib/poplib.py
parentb8a3f581580cc6dc7dd9621bbb41c2b85414eaba (diff)
downloadcpython-1bc7068d7fde0eaf2155240f629bcf80280daff6.zip
cpython-1bc7068d7fde0eaf2155240f629bcf80280daff6.tar.gz
cpython-1bc7068d7fde0eaf2155240f629bcf80280daff6.tar.bz2
Issue #19784: poplib now supports SSLContext.check_hostname and server name
indication for TLS/SSL connections.
Diffstat (limited to 'Lib/poplib.py')
-rw-r--r--Lib/poplib.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/poplib.py b/Lib/poplib.py
index 00ffbcb..23a3517 100644
--- a/Lib/poplib.py
+++ b/Lib/poplib.py
@@ -387,7 +387,9 @@ class POP3:
if context is None:
context = ssl._create_stdlib_context()
resp = self._shortcmd('STLS')
- self.sock = context.wrap_socket(self.sock)
+ server_hostname = self.host if ssl.HAS_SNI else None
+ self.sock = context.wrap_socket(self.sock,
+ server_hostname=server_hostname)
self.file = self.sock.makefile('rb')
self._tls_established = True
return resp
@@ -428,7 +430,9 @@ if HAVE_SSL:
def _create_socket(self, timeout):
sock = POP3._create_socket(self, timeout)
- sock = self.context.wrap_socket(sock)
+ server_hostname = self.host if ssl.HAS_SNI else None
+ sock = self.context.wrap_socket(sock,
+ server_hostname=server_hostname)
return sock
def stls(self, keyfile=None, certfile=None, context=None):