MQTT security hardening
The default Helm charts for esthesis dependencies deploy an MQTT broker with no security configured. This may be convenient to make sure everything works in your environment, however by no means this is a production-ready setup. As esthesis uses the topic names to connect device IDs with the actual devices managed in the system, it is of paramount importance to enable security in MQTT before you expose your installation outside a controlled network.
The following instructions show you how you can enable certificate-based authentication using Eclipse Mosquitto, which is the MQTT broker being used when you set up esthesis using the provided Helm charts.
Create a Certificate Authority and a Certificate
To enable certificate-based authentication and mutual TLS, you need to create a Certificate Authority (CA) and a server certificate.
The CA will be responsible to sign the server certificate, and should be the same CA that signs the certificates used by the devices to connect to the MQTT broker.
The server certificate will be used by the MQTT broker to establish a TLS connections with the devices.
Create a Certificate Authority
To create a Certificate Authority, go to Key Management > CAs and click on the "Create" button. If you have already configured a CA before, you can skip this part. Make sure the CA you create here is the one set as the Root CA under Settings > Security.
Create a server Certificate
You need to create a certificate to be used by the MQTT server to establish TLS. To create a Certificate, go to Key Management > Certificates and click on the "Create" button. Pay attention to the following points:
The certificate should be signed by the CA you created above.
The CN of the certificate should match the domain where the MQTT server is accessible from your devices' perspective. You can add additional domains as SANs (for example, the domain name of the service under which the MQTT server is accessible from within the cluster, i.e. mosquitto).
Download the CA and the Server Certificate
Download the private key and the certificate for the server certificate you created above and the certificate for the CA.
Redeploy the Helm chart enabling TLS
Go to the location where you deployed the esthesis dependencies via executing helmfile sync and add the following environment variables: