Overview
MQTT over TLS encrypts all communication between clients and the broker, protecting credentials and message payloads. The standard port for MQTT over TLS is 8883.Configuration
Basic TLS Listener
config.xml
With Client Certificate Authentication
Client Authentication Modes
| Mode | Description |
|---|---|
NONE | No client certificate required |
OPTIONAL | Client certificate accepted but not required |
REQUIRED | Client must present valid certificate |
Certificate Setup
Generate Self-Signed Certificate (Development)
Using Let’s Encrypt Certificates
Client Connections
Python with TLS
Python with Client Certificate
Java with TLS
Mosquitto CLI with TLS
TLS Protocol Versions
Supported Versions
Troubleshooting
Common Issues
Certificate verification failed
Certificate verification failed
Cause: Client cannot verify server certificateSolutions:
- Ensure CA certificate is correctly installed
- Check certificate expiration date
- Verify hostname matches certificate CN/SAN
- Disable verification for testing (not recommended for production)
Client certificate required
Client certificate required
Cause: Server requires client certificate but client didn’t provide oneSolutions:
- Provide client certificate and key
- Change
client-authentication-modetoOPTIONALorNONE - Verify client certificate is signed by trusted CA
Handshake failure
Handshake failure
Cause: TLS protocol or cipher suite mismatchSolutions:
- Ensure client and server support compatible TLS versions
- Check cipher suite compatibility
- Update client/server libraries
Best Practices
Use Strong Certificates
Use 2048-bit or 4096-bit RSA keys from trusted CAs
Enable TLS 1.2+
Disable TLS 1.0 and 1.1 to prevent vulnerabilities
Regular Rotation
Rotate certificates before expiration
Monitor Expiry
Set up alerts for certificate expiration
Next Steps
TCP Transport
Basic MQTT over TCP
Secure WebSocket
TLS for WebSocket connections
Security Config
Additional security settings
Authentication
Implement authentication extensions