TLS connections with local CA fails on Pico 2 W (RP2350 + CYW43439) with MBEDTLS_ERR_X509_CERT_VERIFY_FAILED · Issue #10339 · adafruit/circuitpython · GitHub
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using a local CA cert generated with OpenSSL to sign a server certificate
Copying CA cert onto CircuitPython board, and loading with ssl_context.load_verify_locations
Connections fail with MBEDTLS_ERR_X509_CERT_VERIFY_FAILED
Originally observed when using this CA and server certificate combination with an Eclipse Mosquitto server and the adafruit_minimqtt library in CircuitPython, but replicated with a simple web server using the same certs and using adafruit_requests on the board
This does not happen with the M5Stack AtomS3 Lite (ESP32-S3) running the same code with same certificates (both original MQTT client and the above test program) and CircuitPython 9.2.6; on that board, the connection succeeds.
This does not happen with other clients using the same CA cert to talk to the same services (Eclipse Mosquitto's mosquitto_sub, and my own MQTT client written in Go)
The CA cert looks as follows, when printed withopenssl x509 -noout -text -in mqtt-ca.crt:
The issue persists Pico 2 W on 9.2.7 (same result and error as 9.2.6).
On 10.0.0-alpha.4 on the Pico 2 W, requests.get() times out. I added some print statements to check how far it got (as it looked like it wouldn't return at all), but eventually it exits with ETIMEOUT. Revised test code (with print statements), as follows, along with 10.0.0-alpha.4 output:
import os
import wifi
import adafruit_connection_manager
import adafruit_requests
ssid = os.getenv("WIFI_SSID")
wifikey = os.getenv("WIFI_PASSWORD")
wifi.radio.connect(ssid, wifikey)
print(f"Radio connected: {wifi.radio.connected}")
pool = adafruit_connection_manager.get_radio_socketpool(wifi.radio)
ssl_context = adafruit_connection_manager.get_radio_ssl_context(wifi.radio)
with open("/mqtt-ca.crt", "rb") as f:
ca_cert = f.read()
ssl_context.load_verify_locations(cadata=ca_cert.decode("utf-8"))
print("Cert loaded")
conn_mgr = adafruit_connection_manager.ConnectionManager(pool)
requests = adafruit_requests.Session(pool, ssl_context)
print("Starting request")
with requests.get("https://192.168.0.62:8111/") as response:
print(response.text)
code.py output:
Radio connected: True
Cert loaded
Starting request
Traceback (most recent call last):
File "code.py", line 22, in <module>
File "adafruit_requests.py", line 711, in get
File "adafruit_requests.py", line 639, in request
File "adafruit_connection_manager.py", line 337, in get_socket
File "adafruit_connection_manager.py", line 249, in _get_connected_socket
OSError: [Errno 116] ETIMEDOUT
Code done running.
Press any key to enter the REPL. Use CTRL-D to reload.
Adafruit CircuitPython 10.0.0-alpha.4 on 2025-05-05; Raspberry Pi Pico 2 W with rp2350a
>>>
I tried connecting to an HTTP endpoint on the same remote host, and this works on both the Pico 2 W (RP2350+CYW) and the AtomS3 Lite (ESP32-S3), confirming the device is indeed connected to wi-fi and that it can talk to the remote host. But the HTTPS request always times out from the Pico 2 W with 10.0.0-alpha4.
I made sure to update adafruit_connection_manager and adafruit_requests to the versions from the 10.x bundle (adafruit-circuitpython-bundle-10.x-mpy-20250511).
10.0.0-alpha4 works fine on the ESP32-S3 (AtomS3 Lite) board.
CircuitPython version and board name
Code/REPL
Behavior
Description
ssl_context.load_verify_locations
The CA cert looks as follows, when printed with
openssl x509 -noout -text -in mqtt-ca.crt
:Additional information
No response
The text was updated successfully, but these errors were encountered: