MQTT: Authentication

✅  Best for: Devices connecting via MQTT.

  • Authentication is handled exclusively via certificates (no tokens).
  • Certificates are tied to a System or Component (Device) in DRIVR.
  • More secure for IoT environments (long-lived authentication).
  • Can be provisioned during manufaturing of a device and installed within the factory

Before generating a certificate, you must create a System.

  1. Navigate to SystemsCreate System
  2. Enter a Name & Confirm the Auto-Generated Code
  3. Click "Create" to finalize the system

Once your System is created, you can proceed to generate a certificate.

  1. Navigate to SystemCertificates
  2. Click Add Certificate
  3. Modify the name & expiry date (if needed)
  4. Click CreateDownload your certificate files

You will receive three files:
✔️ Private Key (.key)
✔️ Certificate (certificate.pem)
✔️ Certificate Authority (CA) (ca.pem)

In this guide, we will use MQTTX as the client to establish connections, publish messages, and subscribe to topics. You can download MQTTX app here or use MQTTX CLI here

After installing MQTTX or your preferred client, use the following command to make sure a connection to the broker can be established

mqttx conn -h mqtt.drivr.cloud -l mqtts -p 8883
            --key my-key.key --cert certificate.pem --ca ca.pem
            
✔ Connected

Alternatively, you can also use the desktop client to establish a connection, you need to make sure that the configuration is correct:

MQTTX Client Test certificate

  • The private key is NOT stored in DRIVR. If lost, you must regenerate the certificate.
  • The Certificate Authority (CA) file is required for secure MQTT connections.
  • The Cerfiticate expiry date can be set via UI

DRIVR UI is the easiest way to create a Certificate. Alternative ways to generate Certificate:

  1. Using the drivr-certificate-client (CLI tool). Further information can be found here.
  2. Manually via OpenSSL – Certificates can be manually created and signed via DRIVR UI. See our guide for automation options.