MQTTS on ESP32C6: Impossible to get a valid Handshake. #98284
Unanswered
JonesKisaka
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello Community,
I’m currently working on a project where an ESP32 running Zephyr OS is supposed to connect securely to my Magistrala IoT application via MQTT with mutual TLS (mTLS).
The IoT application is already up and running — it accepts MQTT connections and messaging from other clients successfully.
On the ESP32 side, I’m using Zephyr’s mqtt library with TLS enabled. I’ve embedded the CA certificate, client certificate, and private key as C arrays in my Zephyr code. During runtime, these certificates are parsed and initialized successfully (as seen in the logs).
However, when the MQTT client attempts to connect, I get the following error logs:

Earlier in the logs, Wi-Fi initializes successfully, DHCP assigns an IP address, and all certificates load without errors.
But the MQTT connection fails at the TLS allocation/connection stage.
Below is the conf:
prj.conf
main.c
What could be causing the mqtt_connect: -2 after successful TLS certificate initialization?
Is there something specific to Zephyr’s net_sock_tls or ESP32’s TLS configuration that could lead to this connection failure?
Any suggestions, sample working configurations, or insights on debugging deeper into the TLS handshake would be greatly appreciated.
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions