summaryrefslogtreecommitdiffstatshomepage
path: root/tests/net_inet
Commit message (Collapse)AuthorAge
* tests/net_inet: Update micropython.org certificate for SSL tests.Damien George2024-09-04
| | | | | | | The Let's Encrypt root certificate has changed so needs updating in this test. Signed-off-by: Damien George <damien@micropython.org>
* tests/net_inet/tls_text_errors.py: Tweak test for newer CPython version.Damien George2024-05-27
| | | | Signed-off-by: Damien George <damien@micropython.org>
* tests/net_inet: Add simpler tls sites test, and skip existing on axtls.Damien George2024-03-29
| | | | | | | | | Ports that use axtls cannot run the `test_tls_sites.py` test because the sites it connects to use advanced ciphers. So skip this test on such ports, and add a new, simpler test that doesn't require certificate verification and works with axtls. Signed-off-by: Damien George <damien@micropython.org>
* extmod/asyncio: Add ssl support with SSLContext.Carlosgg2023-12-14
| | | | | | | | | | | | | | This adds asyncio ssl support with SSLContext and the corresponding tests in `tests/net_inet` and `tests/multi_net`. Note that not doing the handshake on connect will delegate the handshake to the following `mbedtls_ssl_read/write` calls. However if the handshake fails when a client certificate is required and not presented by the peer, it needs to be notified of this handshake error (otherwise it will hang until timeout if any). Finally at MicroPython side raise the proper mbedtls error code and message. Signed-off-by: Carlos Gil <carlosgilglez@gmail.com>
* tests: Update SSL network tests to use SSLContext, and work on CPython.Damien George2023-12-12
| | | | | | | | | | | | Changes are: - use ssl.SSLContext.wrap_socket instead of ssl.wrap_socket - disable check_hostname and call load_default_certs() where appropriate, to get CPython to run the tests correctly - pass socket.AF_INET to getaddrinfo and socket.socket(), to force IPv4 - change tests to use github.com instead of google.com, because certificate validation was failing with google.com Signed-off-by: Damien George <damien@micropython.org>
* extmod/modssl_mbedtls: Add SSLContext certificate methods.Carlosgg2023-12-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit adds: 1) Methods to SSLContext class that match CPython signature: - `SSLContext.load_cert_chain(certfile, keyfile)` - `SSLContext.load_verify_locations(cafile=, cadata=)` - `SSLContext.get_ciphers()` --> ["CIPHERSUITE"] - `SSLContext.set_ciphers(["CIPHERSUITE"])` 2) `sslsocket.cipher()` to get current ciphersuite and protocol version. 3) `ssl.MBEDTLS_VERSION` string constant. 4) Certificate verification errors info instead of `MBEDTLS_ERR_X509_CERT_VERIFY_FAILED`. 5) Tests in `net_inet` and `multi_net` to test these new methods. `SSLContext.load_cert_chain` method allows loading key and cert from disk passing a filepath in `certfile` or `keyfile` options. `SSLContext.load_verify_locations`'s `cafile` option enables the same functionality for ca files. Signed-off-by: Carlos Gil <carlosgilglez@gmail.com>
* extmod/modssl: Add SSLContext class.Damien George2023-06-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit adds the SSLContext class to the ssl module, and retains the existing ssl.wrap_socket() function to maintain backwards compatibility. CPython deprecated the ssl.wrap_socket() function since CPython 3.7 and instead one should use ssl.SSLContext().wrap_socket(). This commit makes that possible. For the axtls implementation: - ssl.SSLContext is added, although it doesn't hold much state because axtls requires calling ssl_ctx_new() for each new socket - ssl.SSLContext.wrap_socket() is added - ssl.PROTOCOL_TLS_CLIENT and ssl.PROTOCOL_TLS_SERVER are added For the mbedtls implementation: - ssl.SSLContext is added, and holds most of the mbedtls state - ssl.verify_mode is added (getter and setter) - ssl.SSLContext.wrap_socket() is added - ssl.PROTOCOL_TLS_CLIENT and ssl.PROTOCOL_TLS_SERVER are added The signatures match CPython: - SSLContext(protocol) - SSLContext.wrap_socket(sock, *, server_side=False, do_handshake_on_connect=True, server_hostname=None) The existing ssl.wrap_socket() functions retain their existing signature. Signed-off-by: Damien George <damien@micropython.org>
* tests: Rename uasyncio to asyncio.Jim Mussared2023-06-19
| | | | | | This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
* tests: Replace umodule with module everywhere.Jim Mussared2023-06-08
| | | | | | This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
* all: Fix spelling mistakes based on codespell check.Damien George2023-04-27
| | | | Signed-off-by: Damien George <damien@micropython.org>
* extmod/modussl_mbedtls: Implement cert_reqs and cadata arguments.Carlosgg2022-07-20
| | | | | | | | | | | | | | | | | Add cert_reqs and cadata keyword-args to ssl.wrap_socket() and ssl.CERT_NONE, ssl.CERT_OPTIONAL, ssl.CERT_REQUIRED constants to allow certificate validation. CPython doesn't accept cadata in ssl.wrap_socket(), but it does in SSLContext.load_verify_locations(), so we use this name to at least match the same name in load_verify_locations(). Add docs for these new arguments, as well as docs for the existing server_hostname argument which is important for certificate validation. Tests are added as well. Signed-off-by: Carlos Gil <carlosgilglez@gmail.com>
* tests/net_inet: Remove broken api.telegram.org from tests.Andrew Leech2022-06-03
| | | | Signed-off-by: Andrew Leech <andrew@alelec.net>
* tests: Use .errno instead of .args[0] for OSError exceptions.Damien George2021-04-23
| | | | Signed-off-by: Damien George <damien@micropython.org>
* tests/net_inet: Add 'Strict-Transport-Security' to exp file.Damien George2021-04-18
| | | | | | Because micropython.org now adds this to the headers. Signed-off-by: Damien George <damien@micropython.org>
* tests: Rename run-tests to run-tests.py for consistency.Damien George2021-03-12
| | | | Signed-off-by: Damien George <damien@micropython.org>
* extmod/modussl: Fix ussl read/recv/send/write errors when non-blocking.Thorsten von Eicken2021-02-17
| | | | | Also fix related problems with socket on esp32, improve docs for wrap_socket, and add more tests.
* extmod/modussl_mbedtls: Integrate shorter error strings.Thorsten von Eicken2020-07-21
| | | | | The stm32 and esp32 ports now use shorter error strings for mbedtls errors. Also, MBEDTLS_ERROR_C is enabled on stm32 by default to get these strings.
* extmod/modussl: Improve exception error messages.Thorsten von Eicken2020-07-20
| | | | | | | | | | | | | | | | | This commit adds human readable error messages when mbedtls or axtls raise an exception. Currently often just an EIO error is raised so the user is lost and can't tell whether it's a cert error, buffer overrun, connecting to a non-ssl port, etc. The axtls and mbedtls error raising in the ussl module is modified to raise: OSError(-err_num, "error string") For axtls a small error table of strings is added and used for the second argument of the OSErrer. For mbedtls the code uses mbedtls' built-in strerror function, and if there is an out of memory condition it just produces OSError(-err_num). Producing the error string for mbedtls is conditional on them being included in the mbedtls build, via MBEDTLS_ERROR_C.
* esp32/modsocket: Fix getaddrinfo to raise on error.Thorsten von Eicken2020-05-09
| | | | | | | | | | This commit fixes the behaviour of socket.getaddrinfo on the ESP32 so it raises an OSError when the name resolution fails instead of returning a [] or a resolution for 0.0.0.0. Tests are added (generic and ESP32-specific) to verify behaviour consistent with CPython, modulo the different types of exceptions per MicroPython documentation.
* tests: Format all Python code with black, except tests in basics subdir.David Lechner2020-03-30
| | | | | | | | | | This adds the Python files in the tests/ directory to be formatted with ./tools/codeformat.py. The basics/ subdirectory is excluded for now so we aren't changing too much at once. In a few places `# fmt: off`/`# fmt: on` was used where the code had special formatting for readability or where the test was actually testing the specific formatting.
* tests/net_inet: Add uasyncio internet tests.Damien George2020-03-26
|
* tests/net_inet: Update tls test to work with CPython and incl new site.Damien George2017-10-26
| | | | | | | | | | CPython only supports the server_hostname keyword arg via the SSLContext object, so use that instead of the top-level ssl.wrap_socket. This allows the test to run on CPython the same as uPy. Also add the "Host:" header to correctly make a GET request (for URLs that are hosted on other servers). This is not strictly needed to test the SSL connection but helps to debug things when printing the response.
* tests/net_inet: Move tests which don't require full Internet to net_hosted.Paul Sokolovsky2017-06-23
| | | | | | | | | | The idea is that these tests can be run with just a test server running on a test host, with device under test connecting to it, instead of requiring Internet connection for testing. Such setup is however WIP, and some tests in net_hosted/ are so far written to connect to Internet, as there're not test server written yet. This is expected to evolve over time.
* tests/net_inet: Add tests for accept and connect in nonblocking mode.Damien George2017-06-21
| | | | | Some of these tests don't require an Internet connection, but here is a good place to put them for now.
* tests/net_inet/test_tls_sites.py: Integration test for SSL connections.Paul Sokolovsky2017-06-21
This attempts to bootstrap network tests for MicroPython. This commits sets test/net_inet/ as place for tests which require access to wide Internet. They aren't intended to be run as part of the main testsuite, instead to be run manually on demand. test_tls_sites.py in particular check that it's possible to establish SSL/TLS connection to select sites on the Internet: few references ones, plus those for which problems were reported, and resolved.