From d75705311ad9406bbb03ae1d510693356cd4f1e3 Mon Sep 17 00:00:00 2001 From: Damien George Date: Sat, 3 Aug 2024 16:20:25 +1000 Subject: [PATCH] examples/network: Use SSLContext instead of old ssl.wrap_socket. `ssl.wrap_socket()` is deprecated in CPython, so use `SSLContext` instead, so the example is a good example to copy. Signed-off-by: Damien George --- examples/network/https_client.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/network/https_client.py b/examples/network/https_client.py index d20f283d74..60ceb83c74 100644 --- a/examples/network/https_client.py +++ b/examples/network/https_client.py @@ -32,7 +32,10 @@ def main(domain, addr_family=0, use_stream=True): s.connect(addr) # Upgrade the socket to a TLS connection. - s = ssl.wrap_socket(s) + ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT) + ctx.check_hostname = False + ctx.verify_mode = ssl.CERT_NONE + s = ctx.wrap_socket(s) print(s) # Send request and read response.