Commit graph

23 commits

Author SHA1 Message Date
eightycc
f495e6d3d5
Merge branch 'adafruit:main' into issue-10191 2025-04-29 09:26:39 -07:00
Dan Halbert
62d16ce61f Fix TLS for v5.4.1 update
Cert bundle code in lib/mbedtls_config was being used, and assumed the older ESP-IDF internal
bundle format, which was changed in ESP-IDF v5.4. Added a wrapper around the ESP-IDF
bundle routines, and stopped using the shared bundle code.

Also fixed extraneous blank lines in mbedtls logging and removed an extraneous, unused, damaged .h.
2025-04-25 15:14:20 -04:00
Scott Shawcroft
91cf8fb83d
Make collect the default 2025-04-24 14:59:07 -07:00
Dan Halbert
bc6f065447 working on compilation errors 2024-09-06 23:10:41 -04:00
3215f6c4ff SSLSocket: handle exceptions during protocol read/write operations
These protocol operations should not raise exceptions, but sometimes
they do. Catch the exception and extract the errno value if available.

At the same time, harmonize the argument types for the underlying C
routines
2024-06-12 16:41:19 -05:00
49a612056e take micropython tricks for selectability of ssl sockets 2024-06-10 12:07:48 -05:00
7969638740 SSLSocket: Add stream protocol
including select. This assumes that the SSL layer is readable/writable
exactly when the underlying socket is readable/writable.
2024-06-07 14:49:35 -05:00
Dan Halbert
3f4d9310ff CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
Dan Halbert
747b7619ea update headers of most CircuitPython-only files 2024-05-17 14:56:28 -04:00
93490c301f Don't close an SSL socket twice 2024-04-17 15:17:37 -05:00
2f53c6edbb ssl: Swallow errors during socket.close()
.. for reasons given in the comment
2024-04-17 15:17:04 -05:00
e5f0579d6c SSLSocket: implement setsockopt (untested) 2024-03-25 09:24:57 -05:00
14a19726f0 Fix return value of accept()
The subscripting to get the `peer` object was wrong.
2024-03-21 14:06:37 -05:00
8c5d9d28d8 ssl: make bind & listen into void functions (they throw exceptions) 2024-03-21 14:06:32 -05:00
f960c5b7c1 SSLSocket: propagate any exception from socket.settimeout directly 2024-03-21 13:54:40 -05:00
b330989704 sslsocket: Simplify handling the timeout value
We're just going to pass it down to the underlying socket, so don't
parse it, multiply it, etc.
2024-03-21 13:54:40 -05:00
c793a021b8 ssl: work on anything implementing the socket protocol
In principle this allows core SSL code to be used with e.g., wiznet
or airlift sockets. It might actually be useful with wiznet ethernet devices
(it's probably not with airlift)
2024-03-21 13:54:40 -05:00
5973c4a86c socketpool: factor out constants
This header can be used by ssl even if there's no core socketpool
2024-03-21 13:54:40 -05:00
3e029a9d0d ssl: Fix "timed out" exceptions
Incorrect error handling in send/recv would raise an OSError with
an incorrect (negative) code.

It's likely that this bug was always happening in the Pico W
implementation, which became the basis of the current shared
implementation.

Push handling of WANT_{READ,WRITE} down into mbedtls_raise_error
and use it in recv_into and send.

Tested by connecting to google.com:443, sending nothing, and trying
to read a byte:

```py
import socketpool, ssl, time, wifi
socket = socketpool.SocketPool(wifi.radio)
ctx = ssl.SSLContext()
with ctx.wrap_socket(socket.socket()) as ss:
    ss.connect(("google.com", 443))
    ss.settimeout(1)
    b = bytearray(1)
    try:
        t0 = time.monotonic()
        ss.recv_into(b)
    except Exception as ee:
        t1 = time.monotonic()
        exc = ee
        print(t1-t0)
        raise exc
```

As desired, an exception `OSError: [Errno 116] ETIMEDOUT` occurred
and the time delta value was 1.0 seconds.

(tested on pycamera)

Closes: #8988
2024-03-04 20:55:32 -06:00
Scott Shawcroft
605c39c8db
Fix ssl.SSLSocket bind() error checking
Non-ssl sockets now return size_t error numbers, not bool.

Fixes #8947
2024-02-20 15:46:06 -08:00
Scott Shawcroft
9f3987aa3c
Require explicit socket port reuse
Doing it implicitly can lead to mistaken socket leaks and reuse.
It now matches CPython.

Fixes #8443
2024-02-16 14:31:19 -08:00
b57c37cd34 espressif: Use mbedtls implementation of ssl module.
the mbedtls version is a bit different so there are some new #ifdefs
needed.

Tested with the ssl test from https://github.com/adafruit/circuitpython/issues/8910
on Adafruit MatrixPortal S3 (no pico w testing done)
2024-02-15 14:26:24 -06:00
9abe273afa mbedtls: move to shared-module
this enables the implementation to be shared among ports.
2024-02-15 13:30:09 -06:00