TBMQ Lite (beta): a self-contained MQTT broker with zero external dependencies
776 Try for free Menu

TBMQ live demo

Try TBMQ in your browser

A free account on our public broker. Open the TBMQ UI and connect your MQTT clients. No credit card required.

Rather run it yourself? Install on your own servers

Cookie preferences

We use cookies for our own analytics, to see how our campaigns perform and, if you allow it, to load the site search from Google. We never sell your data. Necessary cookies keep the site working and cannot be switched off. See our Cookie Policy for details and our Privacy Policy for how we handle personal data.

Security, load balancing and remembering your cookie choice.

Show us which pages people read, how they find the site and where they get stuck, so we can improve it (Google Analytics).

Remember the campaign or partner link you arrived from, so we know which campaign or partner brought you when you sign up or contact us (partner program). We do not use it to build advertising profiles.

Load the site search from Google when you use it. Google sets its own cookies and shows ads in the search results.

MQTT GUIDE

3 min read

MQTT Payload Encryption

Quick answer

Payload encryption means encrypting the message payload itself, inside the MQTT packet, so only the intended recipients can read it — end to end, independent of the transport. It complements TLS: TLS protects data in transit to and from the broker, while payload encryption keeps it unreadable even to the broker.

TLS encrypts the link to the broker — but the broker terminates TLS, so it can read every payload. When the data is sensitive enough that even the broker shouldn’t see it, payload encryption adds an independent layer: encrypt the message body in the clients, and it stays unreadable end to end.

Encrypting the message, not just the link

With payload encryption, the publisher encrypts the payload before it calls publish, and only clients holding the key can decrypt it. The broker still routes the message normally — it just never sees the plaintext. Because this happens above MQTT, it works with any broker that forwards payloads untouched, and it protects the data through the broker and at rest.

TLS protects the link to the broker; payload encryption protects the message itself Publisher encrypts payload Broker sees only ciphertext Subscriber decrypts payload enc(23.5°C) enc(23.5°C) The broker relays the encrypted bytes but cannot read the contents Integrity: sign or MAC the payload so tampering is detectable
Payload encryption keeps the message unreadable even to the broker

Confidentiality and integrity

Confidentiality — encrypt the payload so only key holders can read it; the broker and any intermediary see only ciphertext.
Integrity — add a signature or MAC so a recipient can detect tampering. Authenticated-encryption modes such as AES-GCM give you both at once.

Payload encryption in TBMQ

TBMQ treats every payload as opaque bytes — it never inspects or modifies message content — so client-side payload encryption passes through the broker unchanged, end to end. Combine it with TLS for the transport and authorization to limit topic access. You can also carry metadata like the cipher or key ID in user properties. See the security overview for the layers TBMQ enforces.

Frequently asked questions

What is MQTT payload encryption?

Encrypting the message payload itself — the application data inside the MQTT packet — so only the intended recipients can decrypt it. It is done in the clients, above the MQTT layer, and is independent of whether the transport uses TLS.

How is payload encryption different from TLS?

TLS encrypts the connection between a client and the broker, so the broker decrypts and can see the payload. Payload encryption keeps the payload encrypted through the broker and at rest, so even the broker can’t read it. They are complementary: TLS for the link, payload encryption for the message.

Does the broker need to support payload encryption?

No. Because encryption and decryption happen in the clients and the broker just forwards the bytes, any broker that treats payloads as opaque works. You don’t configure it on the broker.

What about message integrity?

Encryption keeps a payload secret but doesn’t by itself prove it wasn’t altered. To detect tampering, add a signature or message authentication code (MAC) — many authenticated-encryption schemes (e.g. AES-GCM) provide confidentiality and integrity together.

When is payload encryption worth the effort?

When the data is sensitive enough that you don’t want to trust the broker or its operators with it, or when it must stay protected at rest and across intermediaries. For most deployments TLS plus authentication and authorization is enough; payload encryption is defense in depth on top.

Run it yourself

TBMQ is a free, open-source MQTT broker built to scale. Spin it up in minutes or try the live demo — no install required.