Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
add failing test
  • Loading branch information
kevinAlbs committed Oct 14, 2023
commit cf06d90a24d4c0e6b72c3992043aeee7b843fbcb
30 changes: 30 additions & 0 deletions Lib/test/test_ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -4232,6 +4232,36 @@ def test_session_handling(self):
self.assertEqual(str(e.exception),
'Session refers to a different SSLContext.')

def test_session_handling_shared_ciphers(self):
"""
Check the return of SSLSocket.get_shared_ciphers() after an SSL session is reused.
"""
client_context, server_context, hostname = testing_context()

# SSLSocket.session and SSLSession are not compatible with TLS 1.3.
client_context.maximum_version = ssl.TLSVersion.TLSv1_2

server = ThreadedEchoServer(context=server_context, chatty=False)
with server:
with client_context.wrap_socket(socket.socket(),
server_hostname=hostname) as s:
s.connect((HOST, server.port))
session = s.session
self.assertTrue(session)

with client_context.wrap_socket(socket.socket(),
server_hostname=hostname) as s:
s.session = session
s.connect((HOST, server.port))
self.assertEqual(s.session.id, session.id)
self.assertEqual(s.session, session)
self.assertEqual(s.session_reused, True)

# Server thread is joined.
self.assertEqual(len(server.shared_ciphers), 2,
"expected two sets of `shared_ciphers`, got: {}: {}".format(len(server.shared_ciphers), server.shared_ciphers))
self.assertEqual (server.shared_ciphers[0], server.shared_ciphers[1])


@unittest.skipUnless(has_tls_version('TLSv1_3'), "Test needs TLS 1.3")
class TestPostHandshakeAuth(unittest.TestCase):
Expand Down