mosquitto_sub with TLS enabled

cam picture cam · May 7, 2017 · Viewed 8.6k times · Source

I am new to MQTT and I have a frustrating problem.

I have been using MQTT.fx to subscribe to a topic; I have set the:

  • Broker Address
  • Port
  • Client ID
  • Enable SSL/TLS link to image
  • Topic

This works well, however I would like to use mosquitto_sub. I am attempting to subscribe to the same topic in the following way:

mosquitto_sub -h  host -p 8883 -t topic -i client id

This is not working for me. I am using it on a Ubuntu VM.
My powers of observation tell me that I should enable TLS, however I'm not quite sure how to do that, I have stuffed around with certificates and enabling TLS in may ways but have not got the right combo. I know it is required as if I uncheck the SSL/TLS box in MQTT.fx I am unable to connect.

I would really like to replicate what I have in MQTT.fx with mosquitto.

Answer

Khush Bhatia picture Khush Bhatia · May 7, 2017

In the mosquitto_sub command, use the --capath argument to point to /etc/ssl/certs. It needs a pointer to the trusted certificates.