aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2013-12-02 02:56:02 +0100
committerChristian Heimes <christian@cheimes.de>2013-12-02 02:56:02 +0100
commite5b5edfa2ccf2c031be156a03267dc5629feda77 (patch)
treeaadbba4b4cfadf99b963a7db9e18d8fa2bb6c08d /Lib/ftplib.py
parentIssue #19509: Add SSLContext.check_hostname to match the peer's certificate (diff)
downloadcpython-e5b5edfa2ccf2c031be156a03267dc5629feda77.tar.gz
cpython-e5b5edfa2ccf2c031be156a03267dc5629feda77.tar.bz2
cpython-e5b5edfa2ccf2c031be156a03267dc5629feda77.zip
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 1b16e0ae48d..2cc470258e1 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):