Files
micropython/tests/net_inet/ssl_cert.py
Angus Gratton f01373587d tests/net_inet: Use the letsencrypt TLS root cert for all tests.
Previously, mpycert.der was the Intermediate certificate which is regularly
re-issued by Letsencrypt.

Also changes ssl_cert.py to load the cert data from the same file as
test_sslcontext_client.py, so the DER string doesn't have to be pasted
into the source.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2026-03-03 22:52:23 +11:00

28 lines
628 B
Python

import socket
import ssl
if not hasattr(ssl, "CERT_REQUIRED"):
print("SKIP")
raise SystemExit
# For details about this cert, see comment in test_sslcontext_client.py
root_cert_path = "isrgrootx1.der"
def main(use_stream=True):
with open(root_cert_path, "rb") as f:
cadata = f.read()
s = socket.socket()
ai = socket.getaddrinfo("micropython.org", 443)
addr = ai[0][-1]
s.connect(addr)
s = ssl.wrap_socket(
s, cert_reqs=ssl.CERT_REQUIRED, cadata=cadata, server_hostname="micropython.org"
)
s.write(b"GET / HTTP/1.0\r\n\r\n")
print(s.read(17))
s.close()
main()