Skip to content

extmod/uasyncio: add SSL support and fix SSL errors (esp32 primarily) #5815

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from

Conversation

tve
Copy link
Contributor

@tve tve commented Mar 27, 2020

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.

@tve
Copy link
Contributor Author

tve commented Mar 28, 2020

I'm closing this PR in favor of the new ones that take it one step at a time (referenced in the initial comment).

@tve tve closed this Mar 28, 2020
tannewt added a commit to tannewt/circuitpython that referenced this pull request Jan 7, 2022
…n-main

Translations update from Hosted Weblate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant