Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
I’m trying to capture the traffic that my IoT device sends to the broker. It seems that the MQTT packets use TLS 1.2, so I can’t see the traffic in plaintext.
It depends on the exact TLS client and trust store used by the device. If you can make the client log the TLS secrets to a file (like the SSLKEYLOGFILE supported by some libraries), then you can decrypt the traffic with tools like Wireshark. If you can install a custom certificate in the trust store of the device, then you can set up a proxy which intercepts and decrypts the traffic. Or maybe you can disable TLS altogether – it’s not mandatory for MQTT.
No, unfortunately, I have no way to communicate directly with this device. I execute commands on the device through a mobile app, but all messages go through the broker, and I don't have the authority to control either the broker or the device directly.
If you cannot patch or configure the TLS client on the device, then getting the plaintext will be difficult. Remember that TLS was designed specifically to prevent attackers from reading the traffic. Your only hope would be an insecure configuration or an implementation bug. For example, you could set up a proxy to mimic the broker and test how far you can downgrade the TLS/SSL version. You can also inspect the Client Hello message (which is plaintext in TLS 1.2) to check which cipher suites the client supports. If you’re lucky, you’ll find some weakness.
SSLKEYLOGFILEsupported by some libraries), then you can decrypt the traffic with tools like Wireshark. If you can install a custom certificate in the trust store of the device, then you can set up a proxy which intercepts and decrypts the traffic. Or maybe you can disable TLS altogether – it’s not mandatory for MQTT.Client Hellomessage (which is plaintext in TLS 1.2) to check which cipher suites the client supports. If you’re lucky, you’ll find some weakness.