I figured it out. The missing file is v3.ext
, which I was using before when I created my self signed certificates for my HA local domain.
Follow this guide to create the server certificates. Pay attention to the part about common name cn
when you fill out the information via openssl process. I used homeassistant
as the CN since that is where my MQTT Broker add-on was install to. You can view yours by going to Supervisor → System and look for Hostname under HOST.
When you get to step 5, add the v3.ext
file like so before creating the certificate.
sudo openssl x509 -req -in server.csr -CA ca.crt -extfile v3.ext -CAkey ca.key -CAcreateserial -out server.crt -days 720
Paste these line in the v3.ext
, changing the DNS and IP to suite your settings.
DNS = What your HA hostname is
IP = HA local ip address
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
subjectAltName = @alt_names
[alt_names]
DNS = homeassistant
IP = 192.168.1.20
Now Paste these 3 files into your mqtt addon. The files should go under ssl folder
ca.crt
server.crt
server.key
Your Mqtt config file should look like this.
logins: []
customize:
active: true
folder: mosquitto
certfile: server.crt
keyfile: server.key
require_certificate: true
cafile: ca.crt
Restart mqtt and you should see in log that the certificates are found.
Now is time to create a client certificate. Follow this guide to create them. Since we will use the same file from the server certificates, start from Step 1 from that link.
At step 2, under common name, input your mqttuser name. The one you use to login to mqtt.
At sep 3, use the same v3.ext
file when creating the server certificate. The settings should be the same.
sudo openssl x509 -req -in client.csr -CA ca.crt -extfile v3.ext -CAkey ca.key -CAcreateserial -out client.crt -days 720
To test if you can login successfully, you can use mqtt explorer. Paste these 2 files somewhere in your windows.
client.crt
client.key
In your mqtt explorer certificate tab, navigate to these 3 files.
server certificate (CA) = this is the ca.crt from the server
Client certificate = client.crt
Client key = client.key
Make sure you change the settings to login using port 8883
If successful, you should not receive any red error message from mqtt explorer.