HiveMQ Certificate Store with ESP32


I’m trying to implement a secure MQTT Client connection with an ESP32 microcontroller. There is an HiveMQ example for the ESP8266 using the library “CertStoreBearSSL”, but unfortunately, this library seems the be not available for ESP32. Aer there any alternatives or other solutions?

Hello Harald,

Great to see your interest in MQTT and HiveMQ! Check out this post with a learning video : Arduino example with server signed certificate - #9 by Chris .

Please let me know, if that is helpful for your ESP32 project.

Kind regards,
Dasha from HiveMQ Team


It seems that the class “PubSubClient” has no member “setCACert”.
So, how can I set the certificate of the root cert authority?

Sorry, the setCACert member function is part of the “WiFiClientSecure” class.

Can someone help? For esp8266.

What kind of certificate can be used for mass production, it is very inconvenient to use a certificate that may suddenly expire and that needs to be renewed on the client’s device.

Hi Ireshet,

For Cloud, Clients(devices) will only need to trust the server root CA certificate. If it’s set up correctly then clients should always leverage the certificate chain and validate only against the root certificate. You can generate server root CA for your cloud instance and add it to truststore of all your devices.

Please check here to know how to generate a server root CA certificate for a cloud instance.

Kind regards,
Dasha from HiveMQ Team