Breaking: Drop privileges after loading the configuration
This change means privileges are dropped before loading certificates, starting logging, creating the pid file etc. are carried out, so all of those actions must now be changed to ensure that the unprivileged user can carry them out.pull/1886/head
parent
c5fee09c24
commit
2a1df4ddb2
@ -0,0 +1,17 @@
|
||||
# Using Lets Encrypt with Mosquitto
|
||||
|
||||
On Unix like operating systems, Mosquitto will attempt to drop root access as
|
||||
soon as it has loaded its configuration file, but before it has activated any
|
||||
of that configuration. This means that if you are using Lets Encrypt TLS
|
||||
certificates, it will be unable to access the certificates and private keys
|
||||
typically located in /etc/letsencrypt/live/
|
||||
|
||||
To help with this problem there is an example `deploy` renewal hook script in
|
||||
`misc/letsencrypt/mosquitto-copy.sh` which shows how the certificate and
|
||||
private key for a mosquitto broker can be copied to /etc/mosquitto/certs/ and
|
||||
given the correct ownership and permissions so the broker can access them, but
|
||||
no other user can. It then signals Mosquitto to reload the certificates.
|
||||
|
||||
Use of this script allows you to happily use Lets Encrypt certificates with
|
||||
Mosquitto without needing root access for Mosquitto, and without having to
|
||||
restart Mosquitto.
|
@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
|
||||
# This is an example deploy renewal hook for certbot that copies newly updated
|
||||
# certificates to the Mosquitto certificates directory and sets the ownership
|
||||
# and permissions so only the mosquitto user can access them, then signals
|
||||
# Mosquitto to reload certificates.
|
||||
|
||||
# RENEWED_DOMAINS will match the domains being renewed for that certificate, so
|
||||
# may be just "example.com", or multiple domains "www.example.com example.com"
|
||||
# depending on your certificate.
|
||||
|
||||
# Place this script in /etc/letsencrypt/renewal-hoots/deploy/ and make it
|
||||
# executable after editing it to your needs.
|
||||
|
||||
if [ ${RENEWED_DOMAINS} == "my-mosquitto-domain" ]; then
|
||||
# Copy new certificate to Mosquitto directory
|
||||
cp ${RENEWED_LINEAGE}/fullchain.pem /etc/mosquitto/certs/server.pem
|
||||
cp ${RENEWED_LINEAGE}/privkey.pem /etc/mosquitto/certs/server.key
|
||||
|
||||
# Set ownership to Mosquitto
|
||||
chown mosquitto: /etc/mosquitto/certs/server.pem /etc/mosquitto/certs/server.key
|
||||
|
||||
# Ensure permissions are restrictive
|
||||
chmod 0600 /etc/mosquitto/certs/server.pem /etc/mosquitto/certs/server.key
|
||||
|
||||
# Tell Mosquitto to reload certificates and configuration
|
||||
pkill -HUP -x mosquitto
|
||||
fi
|
Loading…
Reference in New Issue