Skip to content

Commit aa596f9

Browse files
authored
Option to not verify upstream ssl (#1459)
1 parent 0bfd7d7 commit aa596f9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

proxy/http/client.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ def client(
3333
scheme: bytes = HTTPS_PROTO,
3434
timeout: float = DEFAULT_TIMEOUT,
3535
content_type: bytes = b'application/x-www-form-urlencoded',
36+
verify: bool = True,
3637
) -> Optional[HttpParser]:
37-
"""Makes a request to remote registry endpoint"""
38+
"""HTTP Client"""
3839
request = build_http_request(
3940
method=method,
4041
url=path,
@@ -53,9 +54,10 @@ def client(
5354
sock: TcpOrTlsSocket = conn
5455
if scheme == HTTPS_PROTO:
5556
try:
56-
ctx = ssl.SSLContext(protocol=(ssl.PROTOCOL_TLS_CLIENT))
57+
ctx = ssl.SSLContext(protocol=ssl.PROTOCOL_TLS_CLIENT)
5758
ctx.options |= DEFAULT_SSL_CONTEXT_OPTIONS
58-
ctx.verify_mode = ssl.CERT_REQUIRED
59+
ctx.check_hostname = verify
60+
ctx.verify_mode = ssl.CERT_NONE if not verify else ssl.CERT_REQUIRED
5961
ctx.load_default_certs()
6062
sock = ctx.wrap_socket(conn, server_hostname=host.decode())
6163
except Exception as exc:

0 commit comments

Comments
 (0)