summaryrefslogtreecommitdiffstats
path: root/Lib/http
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-07-01 07:07:44 (GMT)
committerGitHub <noreply@github.com>2019-07-01 07:07:44 (GMT)
commitee72dda9616258b57c19eb5af00f3e80a3fb8e22 (patch)
tree9dbd2e5796e8f6d265ef932798f836db7686f8af /Lib/http
parentc2684c6d62978e9ce8256c3c7744d0332a2abe4c (diff)
downloadcpython-ee72dda9616258b57c19eb5af00f3e80a3fb8e22.zip
cpython-ee72dda9616258b57c19eb5af00f3e80a3fb8e22.tar.gz
cpython-ee72dda9616258b57c19eb5af00f3e80a3fb8e22.tar.bz2
[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 d1bd6e79da1ee56dc1b902d804216ffd267399db) Co-authored-by: Christian Heimes <christian@python.org> https://bugs.python.org/issue37440
Diffstat (limited to 'Lib/http')
-rw-r--r--Lib/http/client.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/http/client.py b/Lib/http/client.py
index 82908eb..f61267e 100644
--- a/Lib/http/client.py
+++ b/Lib/http/client.py
@@ -1358,6 +1358,9 @@ else:
self.cert_file = cert_file
if context is None:
context = ssl._create_default_https_context()
+ # enable PHA for TLS 1.3 connections if available
+ if context.post_handshake_auth is not None:
+ context.post_handshake_auth = True
will_verify = context.verify_mode != ssl.CERT_NONE
if check_hostname is None:
check_hostname = context.check_hostname
@@ -1366,6 +1369,10 @@ else:
"either CERT_OPTIONAL or CERT_REQUIRED")
if key_file or cert_file:
context.load_cert_chain(cert_file, key_file)
+ # cert and key file means the user wants to authenticate.
+ # enable TLS 1.3 PHA implicitly even for custom contexts.
+ if context.post_handshake_auth is not None:
+ context.post_handshake_auth = True
self._context = context
if check_hostname is not None:
self._context.check_hostname = check_hostname