How to add ALPN parameter when opening socket or ssl wrapping a socket?
It seems like FreeRTOS/mbedTLS support this, is there a way of directly accessing this?
extmod/uasyncio: add SSL support and fix SSL errors (esp32 primarily)
I'm in the process of breaking this PR into multiple smaller ones: #5819, #5825
This PR adds SSL support to uasyncio's open_connection(). open_connection takes an ssl parameter, defaulted to None. When set to True, SSL is used with default settings. When set to a dict SSL is used by wrapping the socket and passing the dict to wrap_socket. In CPython the values None and True function the same, but instead of a dict one would have to pass an SSLContext, which is something MP doesn't have. At least by using a dict nothing prevents an SSLContext from being introduced in the future.
In order not to loose my sanity while trying to work on SSL I also fixed the errors. First, I fixed the return values or raises of send/write/recv/read on non-blocking sockets and ssl sockets on the esp32. The connect_nonblocking.py is significantly expanded to test the various combinations and ensure EINPROGRESS doesn't get returned by a send/write/read/recv and that they all return EINTR/None when they "would block". Along the way I also added send/recv to SSL sockets for overall consistency.
Second, I fixed the mbedtls module to return a proper text error when the connection handshake fails.
I tested against unix micropython, some against CPython, and esp32 MP. Since mbedtls is shared other platforms I don't have need to be tested as well. I suspect this will bring up issues to fix there...
The tests aren't exactly right yet in that they print exception strings which don't work well for the pass/fail checks. I left that in so reviewers can see what's happening. I can remove the printing of the strings when the rest is ready for merge. There are also some additional tests that I need to write.
Before I proceed much further, I'd like to get some feedback so I don't waste my time.