Important: Please read the Qt Code of Conduct -

Mqtt Client SSL/TLS configuration

  • Hi all,
    I've installed a mosquitto broker on a server and now I'm developing an application running on IOS and Android that contains a mqtt client. For this purpose I'm using QtMqtt module and now all work fine without security. Now I want to introduce TLS, but I'm not able to configure correctly the client.

    I've not to specify the certificate, but the sslPeerName(what is it?) to connect to the broker. How can I do? Any suggestion would be appreciated.


  • @Fabel84 not having used the module myself, from the same blog you refer it looks like you need to use method connectToHostEncrypted() "which behaves similar to QSslSocket‘s argument list" and it requires a sslPeerName argument as you mention. From QSslSocket::connectToHostEncrypted() documentation:

    this method enables the usage of a different hostname (sslPeerName) for the certificate validation instead of the one used for the TCP connection (hostName)

    so you provide the name of your peer (in this case the MQTT broker) that you expected the TLS handshake to validate.

Log in to reply