MQTT Projekt IV.

Aus Xinux Wiki
Zur Navigation springen Zur Suche springen

Grundaufbau

Connectivity

ssh

mqtt
  • ssh xinux@opnsense -p 9822
sensor
  • ssh xinux@opnsense -p 9823
aktor
  • ssh xinux@opnsense -p 9824

http

sensor
aktor

Verschlüsselt mit 2FA (Zertifikat + Passwort)

Wir haben eine ca.crt der Auth, ein Server-Zertifikat mqtt.dkbi.int.crt mit mqtt.dkbi.int.key und zwei Client-Zertifikate: sensor.crt/sensor.key und aktor.crt/aktor.key

mqtt

Benutzer anlegen
  • user: xinux
  • pass: 123Start$
  • mosquitto_passwd -c /etc/mosquitto/passwd xinux
Konfiguration kopieren
  • cp /etc/mosquitto/conf.d/defaults.conf.verschlüsselt /etc/mosquitto/conf.d/defaults.conf
;Konfigurationsdatei
listener 8883 0.0.0.0
allow_anonymous false
log_type all
connection_messages true

# Passwortauthentifizierung
password_file /etc/mosquitto/passwd 

# TLS-Server-Zertifikate
certfile /etc/mosquitto/conf.d/mqtt.lab.intern.crt
keyfile /etc/mosquitto/conf.d/mqtt.lab.intern.key
cafile /etc/mosquitto/conf.d/ca.crt

# Client-Zertifikate erforderlich
require_certificate true
use_identity_as_username true 
Restarten
  • systemctl restart mosquitto.service
Checken
  • systemctl status mosquitto.service

Aktor

Der Aktor abonniert (subscribed) die Nachrichten und reagiert darauf.

  • mosquitto_sub -h mqtt.lab.intern -p 8883 --cafile /usr/local/control/ca.crt --cert /usr/local/control/aktor.crt --key /usr/local/control/aktor.key -u xinux -P 123Start$ -t test

Sensor

Der Sensor sendet (published) die Nachrichten an das Topic.

  • mosquitto_pub -h mqtt.lab.intern -p 8883 --cafile /usr/local/control-switch/ca.crt --cert /usr/local/control-switch/sensor.crt --key /usr/local/control-switch/sensor.key -u xinux -P 123Start$ -t test -m "Zertifikat + Passwort"

kali

Hier kann man auf Wireshark mitschneiden. Der Text ist Hexadezimal codiert.

Schaut mal was man sieht.