lv_micropython/tests/extmod/ssl_sslcontext_ciphers.py
Damien George d5b96813dc extmod/modssl_mbedtls: Fix cipher iteration in SSLContext.get_ciphers.
Prior to this commit it would skip every second cipher returned from
mbedtls.

The corresponding test is also updated and now passes on esp32, rp2, stm32
and unix.

Signed-off-by: Damien George <damien@micropython.org>
2024-01-29 15:11:46 +11:00

32 lines
607 B
Python

# Basic test of ssl.SSLContext get_ciphers() and set_ciphers() methods.
try:
import ssl
except ImportError:
print("SKIP")
raise SystemExit
ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
ciphers = ctx.get_ciphers()
for ci in ciphers:
# Only print those ciphers know to exist on all ports.
if ("TLS-ECDHE-ECDSA-WITH-AES" in ci or "TLS-RSA-WITH-AES" in ci) and "CBC" in ci:
print(ci)
ctx.set_ciphers(ciphers[:1])
# Test error cases.
try:
ctx.set_ciphers(ciphers[0])
except TypeError as e:
print(e)
try:
ctx.set_ciphers(["BAR"])
except OSError as e:
print(e)