mirror of
https://github.com/python/cpython.git
synced 2025-07-29 14:15:07 +00:00
[3.8] bpo-37440: Enable TLS 1.3 post-handshake auth in http.client (GH-14448) (GH-14495)
Post-handshake authentication is required for conditional client cert authentication with TLS 1.3.
https://bugs.python.org/issue37440
(cherry picked from commit d1bd6e79da
)
Co-authored-by: Christian Heimes <christian@python.org>
https://bugs.python.org/issue37440
This commit is contained in:
parent
c2684c6d62
commit
ee72dda961
4 changed files with 32 additions and 0 deletions
|
@ -1745,6 +1745,24 @@ class HTTPSTest(TestCase):
|
|||
self.assertEqual(h, c.host)
|
||||
self.assertEqual(p, c.port)
|
||||
|
||||
def test_tls13_pha(self):
|
||||
import ssl
|
||||
if not ssl.HAS_TLSv1_3:
|
||||
self.skipTest('TLS 1.3 support required')
|
||||
# just check status of PHA flag
|
||||
h = client.HTTPSConnection('localhost', 443)
|
||||
self.assertTrue(h._context.post_handshake_auth)
|
||||
|
||||
context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
|
||||
self.assertFalse(context.post_handshake_auth)
|
||||
h = client.HTTPSConnection('localhost', 443, context=context)
|
||||
self.assertIs(h._context, context)
|
||||
self.assertFalse(h._context.post_handshake_auth)
|
||||
|
||||
h = client.HTTPSConnection('localhost', 443, context=context,
|
||||
cert_file=CERT_localhost)
|
||||
self.assertTrue(h._context.post_handshake_auth)
|
||||
|
||||
|
||||
class RequestBodyTest(TestCase):
|
||||
"""Test cases where a request includes a message body."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue