From f29c697455b8ef3855adf9147f504768e5c19c63 Mon Sep 17 00:00:00 2001 From: Ross Scroggs Date: Tue, 26 Nov 2024 13:43:55 -0800 Subject: [PATCH] Updated code that uses the Domain Shared Contacts API with an HTTPS proxy to avoid a trap: --- src/gam/atom/http.py | 4 +++- src/gam/atom/http_core.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gam/atom/http.py b/src/gam/atom/http.py index 44bec029..df12f297 100644 --- a/src/gam/atom/http.py +++ b/src/gam/atom/http.py @@ -247,7 +247,9 @@ class ProxiedHttpClient(HttpClient): # Trivial setup for ssl socket. sslobj = None if ssl_imported: - sslobj = ssl.wrap_socket(p_sock, None, None) + context = ssl.SSLContext(ssl.PROTOCOL_TLS) + context.minimum_version = ssl.TLSVersion.TLSv1_2 + sslobj = context.wrap_socket(p_sock, server_hostname=url.host) else: sock_ssl = socket.ssl(p_sock, None, None) sslobj = http.client.FakeSocket(p_sock, sock_ssl) diff --git a/src/gam/atom/http_core.py b/src/gam/atom/http_core.py index 201ecf7c..875bb1e7 100644 --- a/src/gam/atom/http_core.py +++ b/src/gam/atom/http_core.py @@ -568,7 +568,7 @@ class ProxiedHttpClient(HttpClient): context.minimum_version = ssl.TLSVersion.TLSv1_2 sslobj = context.wrap_socket(p_sock, server_hostname=uri.host) else: - sock_ssl = socket.ssl(p_sock, None, Nonesock_) + sock_ssl = socket.ssl(p_sock, None, None) sslobj = http.client.FakeSocket(p_sock, sock_ssl) # Initalize httplib and replace with the proxy socket. connection = http.client.HTTPConnection(proxy_uri.host)