summaryrefslogtreecommitdiffstats
path: root/Lib/ftplib.py
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2013-12-02 01:56:02 (GMT)
committerChristian Heimes <christian@cheimes.de>2013-12-02 01:56:02 (GMT)
commite5b5edfa2ccf2c031be156a03267dc5629feda77 (patch)
treeaadbba4b4cfadf99b963a7db9e18d8fa2bb6c08d /Lib/ftplib.py
parent1aa9a75fbff2333fd07574e3de8710c629483258 (diff)
downloadcpython-e5b5edfa2ccf2c031be156a03267dc5629feda77.zip
cpython-e5b5edfa2ccf2c031be156a03267dc5629feda77.tar.gz
cpython-e5b5edfa2ccf2c031be156a03267dc5629feda77.tar.bz2
Issue #19781: ftplib now supports SSLContext.check_hostname and server name
indication for TLS/SSL connections.
Diffstat (limited to 'Lib/ftplib.py')
-rw-r--r--Lib/ftplib.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/ftplib.py b/Lib/ftplib.py
index 1b16e0a..2cc4702 100644
--- a/Lib/ftplib.py
+++ b/Lib/ftplib.py
@@ -748,7 +748,9 @@ else:
resp = self.voidcmd('AUTH TLS')
else:
resp = self.voidcmd('AUTH SSL')
- self.sock = self.context.wrap_socket(self.sock)
+ server_hostname = self.host if ssl.HAS_SNI else None
+ self.sock = self.context.wrap_socket(self.sock,
+ server_hostname=server_hostname)
self.file = self.sock.makefile(mode='r', encoding=self.encoding)
return resp
@@ -787,7 +789,9 @@ else:
def ntransfercmd(self, cmd, rest=None):
conn, size = FTP.ntransfercmd(self, cmd, rest)
if self._prot_p:
- conn = self.context.wrap_socket(conn)
+ server_hostname = self.host if ssl.HAS_SNI else None
+ conn = self.context.wrap_socket(conn,
+ server_hostname=server_hostname)
return conn, size
def abort(self):