My team and I are working on a IOT home automation system. It is crucial for our system to handle realtime updates and dependencies between devices through the mqtt protocol. Everything seemed to work just fine, before we decided to move to MQTTS. We issued the SSL certificate with the help of Ngix Proxy Manager, after inserting the letsencrypt directory to the docker compose file and running it, the broker persistently rejects connections.
When checking the mosquitto-log, I get an output of: Certificate Verify error
Docker-compose.yml :
version: "3.7"
services:
app:
image: 'jc21/nginx-proxy-manager:latest'
restart: unless-stopped
ports:
- '80:80'
- '81:81'
- '443:443'
volumes:
- ./data:/data
- ./letsencrypt:/etc/letsencrypt
pyth:
image: 'foxide123/prediction-model-image:1.2'
restart: always
ports:
- '5000:5000'
volumes:
- ./letsencrypt:/etc/letsencrypt
mqtt:
container_name: ohmio_mqtt
image: ohmio_mqtt_image
restart: always
volumes:
- ./mosquitto.conf:/mosquitto/config/mosquitto.conf
- ./pwfile:/mosquitto/config/pwfile
- ./data:/mosquitto/data/
- ./letsencrypt:/mosquitto/certificates
- ./log:/mosquitto/log
ports:
- "8883:8883"
The mosquitto-conf file (/etc/mosquitto/mosquitto.config) :
listener 8883 0.0.0.0
certfile /mosquitto/certificates/live/npm-3/fullchain.pem
keyfile /mosquitto/certificates/live/npm-3/privkey.pem
allow_anonymous false
password_file /mosquitto/config/pwfile/passwd
persistence true
persistence_location /mosquitto/data/
log_dest file /mosquitto/log/mosquitto.log
log_type all
require_certificate true
Configuration file for Ngix:
server{
listen 8883;
server_name mqtt.ohmio.org
ssl_certificate nginx_npm/letsencrypt/live/npm-3/fullchain.pem
ssl_certficiate nginx_npm/letsencrypt/live/npm-3/privkey.pem
ssl_protocols TLSv1.2 TLSv1.3;
}
At first I tried to directly generate cerificate through "letsencrypt", the error I got was: Certificate Verify error Later one I decided to use Ngix proxy manager for generating the certificates, the error presisted the same.
The problem is
require_certificate trueFrom the
mosquitto.confman pageThis is saying the clients MUST supply a client certificate to identify themselves to the broker when opening the connection.
This option requires a matching
cafileorcapathentry which points to the CA certificate that issued the clients certificates so they can be verified.In this case it looks like you are using username/passwords to authenticate/identify clients not client certificates so you need to remove the
require_certificate trueoption from themosquitto.conf