Hi,
I have a new RaspPi 4 and run OHAB 3.2.0. Using openhabian-config I installed MQTT.
The unencrypted way is working without problems.
Now I wanted to get MQTT using SSL but I could not get it working.
Here is what I did (thanks to: tpyo kingg at Some Notes on setting up MQTT over TLS) :
- Certificate Authority:
cd /etc/mosquitto/ca_certificates/
sudo openssl req \
-new \
-x509 \
-days 400 \
-extensions v3_ca \
-subj '/C=FI/L=Some City/CN=192.168.1.140' \
-keyout mosquitto-certificate-authority.key \
-out mosquitto-certificate-authority.crt
- TLS with Authenticated MQTT - the broker
cd /etc/mosquitto/certs/
sudo openssl genrsa \
-out mqtt-server.key \
2048
- Make signing request:
sudo openssl req \
-new \
-out mqtt-server.csr \
-key mqtt-server.key \
-subj '/C=FI/L=Some City/CN=192.168.1.140'
- Sign key using the Certificate Authority:
sudo openssl x509 \
-req \
-days 367 \
-CA ../ca_certificates/mosquitto-certificate-authority.crt \
-CAkey ../ca_certificates/mosquitto-certificate-authority.key \
-CAcreateserial \
-in mqtt-server.csr \
-out mqtt-server.crt
- Create new encryption file:
sudo nano /etc/mosquitto/conf.d/encryption.conf
- Add following lines into that file:
port 8883
cafile /etc/mosquitto/ca_certificates/mosquitto-certificate-authority.crt
keyfile /etc/mosquitto/certs/mqtt-server.key
certfile /etc/mosquitto/certs/mqtt-server.crt
tls_version tlsv1.2
-
Save that file using CTRL-X and then Y (for Yes)
-
Restart mosquitto:
sudo systemctl restart mosquitto
But unfortunately it comes up with follwoing error:
Job for mosquitto.service failed because the control process exited with error code.
See βsystemctl status mosquitto.serviceβ and βjournalctl -xeβ for details.
If I run
systemctl status mosquitto.service
I get this:
mosquitto.service - Mosquitto MQTT Broker
Loaded: loaded (/lib/systemd/system/mosquitto.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2022-02-06 18:55:14 CET; 48s ago
Docs: man:mosquitto.conf(5)
man:mosquitto(8)
Process: 6509 ExecStartPre=/bin/mkdir -m 740 -p /var/log/mosquitto (code=exited, status=0/SUCCESS)
Process: 6510 ExecStartPre=/bin/chown mosquitto /var/log/mosquitto (code=exited, status=0/SUCCESS)
Process: 6511 ExecStartPre=/bin/mkdir -m 740 -p /run/mosquitto (code=exited, status=0/SUCCESS)
Process: 6512 ExecStartPre=/bin/chown mosquitto /run/mosquitto (code=exited, status=0/SUCCESS)
Process: 6513 ExecStart=/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf (code=exited, status=1/FAILURE)
Main PID: 6513 (code=exited, status=1/FAILURE)
CPU: 56ms
Feb 06 18:55:14 OHAB3RPI4 systemd[1]: mosquitto.service: Scheduled restart job, restart counter is at 5.
Feb 06 18:55:14 OHAB3RPI4 systemd[1]: Stopped Mosquitto MQTT Broker.
Feb 06 18:55:14 OHAB3RPI4 systemd[1]: mosquitto.service: Start request repeated too quickly.
Feb 06 18:55:14 OHAB3RPI4 systemd[1]: mosquitto.service: Failed with result 'exit-code'.
Feb 06 18:55:14 OHAB3RPI4 systemd[1]: Failed to start Mosquitto MQTT Broker.
What I am missing please?
Thanks for any helpβ¦