diff options
author | Felix Dörre <felix@dogcraft.de> | 2024-02-01 12:07:06 +0000 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2024-02-07 12:58:52 +1100 |
commit | b802f0f8abf3c198d4d373d934f4ab13ec1552f9 (patch) | |
tree | de1e689a592646a3f321a0a9a452cb455822ded2 /tests/extmod/tls_sslcontext_ciphers.py | |
parent | f8f1f29ac0b5ef837e7c277b2777080c1d82e080 (diff) | |
download | micropython-b802f0f8abf3c198d4d373d934f4ab13ec1552f9.tar.gz micropython-b802f0f8abf3c198d4d373d934f4ab13ec1552f9.zip |
extmod/modtls: Move the native ssl module to tls.
The current `ssl` module has quite a few differences to the CPython
implementation. This change moves the MicroPython variant to a new `tls`
module and provides a wrapper module for `ssl` (in micropython-lib).
Users who only rely on implemented comparible behavior can continue to use
`ssl`, while users that rely on non-compatible behavior should switch to
`tls`. Then we can make the facade in `ssl` more strictly adhere to
CPython.
Signed-off-by: Felix Dörre <felix@dogcraft.de>
Diffstat (limited to 'tests/extmod/tls_sslcontext_ciphers.py')
-rw-r--r-- | tests/extmod/tls_sslcontext_ciphers.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/extmod/tls_sslcontext_ciphers.py b/tests/extmod/tls_sslcontext_ciphers.py new file mode 100644 index 0000000000..43f94fb19a --- /dev/null +++ b/tests/extmod/tls_sslcontext_ciphers.py @@ -0,0 +1,31 @@ +# Basic test of tls.SSLContext get_ciphers() and set_ciphers() methods. + +try: + import tls +except ImportError: + print("SKIP") + raise SystemExit + + +ctx = tls.SSLContext(tls.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) |