Add labs
This commit is contained in:
55
04-mosquitto/lab05/lab.txt
Normal file
55
04-mosquitto/lab05/lab.txt
Normal file
@ -0,0 +1,55 @@
|
||||
= Mosquitto mit custom TLS Zertifikat
|
||||
|
||||
|
||||
Erstellen Sie ein self-signed (CA) Zertifikat.
|
||||
|
||||
|
||||
$ openssl req -new -x509 -newkey rsa:4096 -nodes -keyout ca-key.pem -out ca-cert.pem \
|
||||
-days 365 -subj "/CN=My-CA" -addext "basicConstraints=critical,CA:TRUE" \
|
||||
-addext "keyUsage=critical,keyCertSign,cRLSign"
|
||||
|
||||
|
||||
Signieren Sie damit ein selbst erstelltes Zertifikat für Mosquitto.
|
||||
|
||||
$ openssl genrsa -out key.pem 2048
|
||||
$ openssl req -new -key key.pem -out request.pem -subj "/CN=localhost" \
|
||||
-addext 'subjectAltName=DNS:localhost,IP:127.0.0.1' \
|
||||
-addext "keyUsage=digitalSignature,keyEncipherment" \
|
||||
-addext "extendedKeyUsage=serverAuth"
|
||||
|
||||
$ openssl x509 -req -days 365 -in request.pem -CA ca-cert.pem -CAkey ca-key.pem \
|
||||
-set_serial 01 -out cert.pem -copy_extensions copyall
|
||||
|
||||
Konfigurieren Sie damit einen zusätzlichen Listener in Mosquitto (`certfile`, `keyfile`) Port 8883
|
||||
|
||||
|
||||
listener 1883
|
||||
listener_allow_anonymous true
|
||||
password_file /mosquitto/config/users.txt
|
||||
acl_file /mosquitto/config/acl.txt
|
||||
|
||||
listener 8883
|
||||
listener_allow_anonymous true
|
||||
certfile /mosquitto/config/cert.pem
|
||||
keyfile /mosquitto/config/key.pem
|
||||
|
||||
|
||||
Konfigurieren Sie das CA Zertifikat im Client und greifen per TLS auf Mosquitto zu.
|
||||
|
||||
$ docker run --rm -it --init --net host -v $PWD:/data eclipse-mosquitto \
|
||||
mosquitto_pub --port 8883 -V 5 --qos 1 --topic freeforall --message "this is secure" \
|
||||
--cafile /data/ca-cert.pem --debug
|
||||
|
||||
|
||||
Was passiert, wenn das CA Zertifikat nicht angegeben wird?
|
||||
|
||||
$ docker run --rm -it --init --net host -v $PWD:/data eclipse-mosquitto \
|
||||
mosquitto_pub --port 8883 -V 5 --qos 1 --topic freeforall --message "this is secure" \
|
||||
--debug
|
||||
|
||||
|
||||
Optional können Sie auch Username/Passwort Credentials ergänzen
|
||||
|
||||
$ docker run --rm -it --init --net host -v $PWD:/data eclipse-mosquitto \
|
||||
mosquitto_pub --port 8883 -V 5 --qos 1 --topic announcements --message "all secure" \
|
||||
--cafile /data/ca-cert.pem --username thomas -P geheim --debug
|
||||
Reference in New Issue
Block a user