Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2ec530c

Browse files
authored
[2.7] bpo-34391: Fix ftplib test for TLS 1.3 (GH-8787) (GH-8791)
Read from data socket to avoid "[SSL] shutdown while in init" exception during shutdown of the dummy server. Signed-off-by: Christian Heimes <[email protected]> <!-- issue-number: [bpo-34391](https://www.bugs.python.org/issue34391) --> https://bugs.python.org/issue34391 <!-- /issue-number -->. (cherry picked from commit 1590c39) Co-authored-by: Christian Heimes <[email protected]>
1 parent 00aebab commit 2ec530c

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

Lib/test/test_ftplib.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,20 +675,25 @@ def test_data_connection(self):
675675
# clear text
676676
sock = self.client.transfercmd('list')
677677
self.assertNotIsInstance(sock, ssl.SSLSocket)
678+
self.assertEqual(sock.recv(1024), LIST_DATA.encode('ascii'))
678679
sock.close()
679680
self.assertEqual(self.client.voidresp(), "226 transfer complete")
680681

681682
# secured, after PROT P
682683
self.client.prot_p()
683684
sock = self.client.transfercmd('list')
684685
self.assertIsInstance(sock, ssl.SSLSocket)
686+
# consume from SSL socket to finalize handshake and avoid
687+
# "SSLError [SSL] shutdown while in init"
688+
self.assertEqual(sock.recv(1024), LIST_DATA.encode('ascii'))
685689
sock.close()
686690
self.assertEqual(self.client.voidresp(), "226 transfer complete")
687691

688692
# PROT C is issued, the connection must be in cleartext again
689693
self.client.prot_c()
690694
sock = self.client.transfercmd('list')
691695
self.assertNotIsInstance(sock, ssl.SSLSocket)
696+
self.assertEqual(sock.recv(1024), LIST_DATA.encode('ascii'))
692697
sock.close()
693698
self.assertEqual(self.client.voidresp(), "226 transfer complete")
694699

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix ftplib test for TLS 1.3 by reading from data socket.

0 commit comments

Comments
 (0)