Skip to content
This repository was archived by the owner on May 7, 2025. It is now read-only.

Fix SSL context creation for MicroPython v1.23.0 #82

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

u1f992
Copy link

@u1f992 u1f992 commented Jun 17, 2024

Starting with MicroPython v1.23.0, the ussl module is no longer provided and only the ssl module is available (at least on the rp2 port).

Therefore, l.235 in BlynkLib.py falls back to l.238 and AttributeError is raised.

MicroPython v1.23.0 on 2024-06-02; Raspberry Pi Pico W with RP2040

Type "help()" for more information.

>>> import ussl
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: no module named 'ussl'
>>> import ssl
>>> dir(ssl)
['__class__', '__name__', 'CERT_NONE', 'CERT_OPTIONAL', 'CERT_REQUIRED', 'MBEDTLS_VERSION', 'PROTOCOL_TLS_CLIENT', 'PROTOCOL_TLS_SERVER', 'SSLContext', '__dict__', '__file__', 'tls', 'wrap_socket', '__version__']
>>> ssl.create_default_context()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'create_default_context'

Instead of ssl.create_default_context(), we can use ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT) to avoid the problem.

@Astrophsica
Copy link

I'm +1 on this pull request. After reading the error message and researching the documentation, I realised it was replaced with ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT) . @vshymanskyy It would be great if you could merge this pull request, as a lot of people rely on this library (via YT tutorials).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants