Browse Source

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 <damien@micropython.org>
pull/15588/head
Damien George 3 months ago
parent
commit
d75705311a
  1. 5
      examples/network/https_client.py

5
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.

Loading…
Cancel
Save