MQTT SSL/TLS message exchange → Using Mosquitto Client
We will try MQTT communication by applying MQTT SSL/TLS security using mosquitto client.
See How to Create a Certificate and Key with OpenSSL for SSL/TLS → § TCP, SSL/TLS, 키와 인증서 만들기 | momoiot
The test system configuration is as follows.
1. MQTT Broker/Server Setup
♦ Open the mosquitto configuration file (conf) → TLS/SSL settings for communication → Save
2. Start MQTT Broker
Run the Mosquitto broker from a Windows command on your PC. → D:\mosquitto>mosquitto -v -c mosquitto.conf
3. Run an MQTT client subscribing to the topic “/momo”.
Run a Mosquitto client that subscribes to MQTT messages published to the topic “/momo”.
→ D:\mosquitto>mosquitto_sub -v -t /momo -p 8883 -h 192.168.0.2 –cafile D:\cert\ca.crt –cert D:\cert\client.crt –key D:\cert\client.key
♦ The log message output from the MQTT server according to the connection of a new client is as follows.
4. Launch an MQTT client that publishes messages on the topic “/momo”.
Run the Mosquitto client that publish MQTT messages to the topic “/momo”.
→ D:\mosquitto>mosquitto_pub -t /momo -p 8883 -h 192.168.0.2 –cafile d:\cert\ca.crt –cert d:\cert\client.crt –key d:\cert\client.key -m “hello, momo!”
♦ The message reception result of the MQTT client subscribing to the topic “/momo” is as follows.