(self)
| 4539 | @requires_tls_version('TLSv1_3') |
| 4540 | @unittest.skipUnless(ssl.HAS_PSK, 'TLS-PSK disabled on this OpenSSL build') |
| 4541 | def test_psk_tls1_3(self): |
| 4542 | psk = bytes.fromhex('deadbeef') |
| 4543 | identity_hint = 'identity-hint' |
| 4544 | client_identity = 'client-identity' |
| 4545 | |
| 4546 | def client_callback(hint): |
| 4547 | # identity_hint is not sent to the client in TLS 1.3 |
| 4548 | self.assertIsNone(hint) |
| 4549 | return client_identity, psk |
| 4550 | |
| 4551 | def server_callback(identity): |
| 4552 | self.assertEqual(identity, client_identity) |
| 4553 | return psk |
| 4554 | |
| 4555 | client_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT) |
| 4556 | client_context.check_hostname = False |
| 4557 | client_context.verify_mode = ssl.CERT_NONE |
| 4558 | client_context.minimum_version = ssl.TLSVersion.TLSv1_3 |
| 4559 | client_context.set_ciphers('PSK') |
| 4560 | client_context.set_psk_client_callback(client_callback) |
| 4561 | |
| 4562 | server_context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER) |
| 4563 | server_context.minimum_version = ssl.TLSVersion.TLSv1_3 |
| 4564 | server_context.set_ciphers('PSK') |
| 4565 | server_context.set_psk_server_callback(server_callback, identity_hint) |
| 4566 | |
| 4567 | server = ThreadedEchoServer(context=server_context) |
| 4568 | with server: |
| 4569 | with client_context.wrap_socket(socket.socket()) as s: |
| 4570 | s.connect((HOST, server.port)) |
| 4571 | |
| 4572 | @unittest.skip("TODO: RUSTPYTHON; Hangs") |
| 4573 | def test_thread_recv_while_main_thread_sends(self): |
nothing calls this directly
no test coverage detected