Chapter 10. MQTT Network with self-signed certs
Some text here.
Note
from stackoverflow
-
How to query a key
opesssl x509 -text -in xxx.crt -
Make the CA key and self-signed cert.
openssl req -x509 -nodes \ -newkey RSA:2048 \ -keyout mqtt_ca.key \ -days 3650 \ -out mqtt_ca.crt \ -subj '/C=US/ST=CA/L=SF/O=S/CN=hostname' -
Make the client or server key and signing request.
openssl req -nodes \ -newkey rsa:2048 \ -keyouthostname.key \ -outhostname.csr \ -subj '/C=US/ST=CA/L=SF/O=S/CN=hostname' -
Sign the request with the CA key, producing a signed cert.
Note
The
-extfilestuff was for local DNS; not necessary for MQTT.openssl x509 -req \ -CA ../mqtt_ca.crt \ -CAkey mqtt_ca.key \ -inhostname.csr \ -outhostname.crt \ -days 365 \ -CAcreateserial \ -extfile <(printf "subjectAltName = DNS.0:hostname2\nauthorityKeyIdentifier = keyid,issuer\nbasicConstraints = CA:FALSE\nkeyUsage = digitalSignature, keyEncipherment\nextendedKeyUsage=serverAuth") -
Install certificates in default MQTT locations
Copy the certificates to the standard places and standard file names.
sudo cp ../broker/mqtt_broker.crt /etc/mosquitto/ca_certificates/mqtt_ca.pemsudo cphostname.crt /etc/mosquitto/certs/client_cert.pemsudo cphostname.key /etc/mosquitto/certs/client_key.pem