Description
In some cases, the ussl.wrap_socket
function fails with a nondescript error:
>>> import ussl, usocket
>>> s = usocket.socket()
>>> s.connect(('185.8.236.214', 443))
>>> s = ussl.wrap_socket(s, server_hostname="aladinonline.androworks.org")
mbedtls_ssl_handshake error: -4290
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 5] EIO
This doesn't seem to be a network problem as requests to other pages work well in the same session. This is in fact the only page I've run into this issue with, and I can't figure out what's wrong with its TLS setup.
I initially ran into this when using the urllib.urequest.urlopen
function and I believed this was a micropython-lib bug, so I didn't post the issue here (original issue was micropython/micropython-lib#374), but I found out later that the bug wasn't present in the Micropython version 1.12 and that it was probably introduced by commit 3032ae1, which switches the version of ESP-IDF used to build Micropython for ESP32. Even though I managed to replicate the bug only using the undocumented parameter server_hostname
of wrap_socket
function, I really think this is a bug in Micropython (or some underlying library), not in micropython-lib.