BASIC CODE for MQTT connection

Hello Jose,

Thanks for your interest in MQTT and HiveMQ MQTT Broker!

Looking at your code, it seems that the issue is the “cafile”:

MQTT “SETPARAM”, “cafile”,"/usr/BaltimoreCyberTrustRoot.pem"

You would need to use HiveMQ Broker “server.pem”.
You can create the Server Certificate file using the openssl s_client towards your HiveMQ Cloud broker cluster:

openssl s_client -connect XXXXXXXXXXXXXXXXXXXXX.s2.eu.hivemq.cloud:8883 -showcerts < /dev/null 2> /dev/null | sed -n '/BEGIN/,/END/p' > server.pem

This will create a file called “server.pem”, which you can use as “Server Certiciate”.

Please let me know if this helps.

Kind regards,
Dasha from HiveMQ Team