mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
Fix issue #8806: add SSL contexts support to ftplib
This commit is contained in:
parent
60853211da
commit
a67299e757
4 changed files with 49 additions and 6 deletions
|
@ -719,6 +719,29 @@ class TestTLS_FTPClass(TestCase):
|
|||
finally:
|
||||
self.client.ssl_version = ssl.PROTOCOL_TLSv1
|
||||
|
||||
def test_context(self):
|
||||
self.client.quit()
|
||||
ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
|
||||
self.assertRaises(ValueError, ftplib.FTP_TLS, keyfile=CERTFILE,
|
||||
context=ctx)
|
||||
self.assertRaises(ValueError, ftplib.FTP_TLS, certfile=CERTFILE,
|
||||
context=ctx)
|
||||
self.assertRaises(ValueError, ftplib.FTP_TLS, certfile=CERTFILE,
|
||||
keyfile=CERTFILE, context=ctx)
|
||||
|
||||
self.client = ftplib.FTP_TLS(context=ctx, timeout=2)
|
||||
self.client.connect(self.server.host, self.server.port)
|
||||
self.assertNotIsInstance(self.client.sock, ssl.SSLSocket)
|
||||
self.client.auth()
|
||||
self.assertIs(self.client.sock.context, ctx)
|
||||
self.assertIsInstance(self.client.sock, ssl.SSLSocket)
|
||||
|
||||
self.client.prot_p()
|
||||
sock = self.client.transfercmd('list')
|
||||
self.assertIs(self.client.sock.context, ctx)
|
||||
self.assertIsInstance(sock, ssl.SSLSocket)
|
||||
sock.close()
|
||||
|
||||
|
||||
class TestTimeouts(TestCase):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue