Skip to main content

External MQTT Broker TLS (OwnTracks)

This page explains how to configure GeoPulse backend to connect to an external MQTT broker over TLS.

Important scope:

  • This affects only the backend connection from GeoPulse to your external broker.
  • The bundled GeoPulse Mosquitto deployment remains non-TLS by default (port 1883) and is unchanged.

What You Need

At minimum:

  • GEOPULSE_MQTT_ENABLED=true
  • External broker host and port (GEOPULSE_MQTT_BROKER_HOST, GEOPULSE_MQTT_BROKER_PORT)
  • GEOPULSE_MQTT_TLS_ENABLED=true

Depending on your broker TLS setup, you may also need truststore/keystore files mounted into geopulse-backend.

Variables

Core MQTT

VariableRequiredDefaultNotes
GEOPULSE_MQTT_ENABLEDYesfalseMust be true to enable MQTT integration.
GEOPULSE_MQTT_BROKER_HOSTYesgeopulse-mosquittoSet to your external broker host.
GEOPULSE_MQTT_BROKER_PORTYes1883Use your TLS port (commonly 8883).
GEOPULSE_MQTT_USERNAMEUsuallygeopulse_mqtt_adminDepends on broker auth policy.
GEOPULSE_MQTT_PASSWORDUsuallygeopulse_mqtt_pass_123Depends on broker auth policy.

TLS

VariableRequiredDefaultNotes
GEOPULSE_MQTT_TLS_ENABLEDYes (for TLS)falseEnables TLS for backend MQTT client (ssl://).
GEOPULSE_MQTT_TLS_PROTOCOLNoTLSv1.2Typical values: TLSv1.2, TLSv1.3.
GEOPULSE_MQTT_TLS_TRUSTSTORE_PATHDepends(empty)Required for private CA/self-signed broker certs. Optional for public CA brokers trusted by JVM.
GEOPULSE_MQTT_TLS_TRUSTSTORE_PASSWORDIf truststore path set(empty)Password for truststore file.
GEOPULSE_MQTT_TLS_TRUSTSTORE_TYPENoPKCS12Common values: PKCS12, JKS.
GEOPULSE_MQTT_TLS_KEYSTORE_PATHDepends(empty)Required only when broker enforces mTLS (client certificate auth).
GEOPULSE_MQTT_TLS_KEYSTORE_PASSWORDIf keystore path set(empty)Password for client keystore file.
GEOPULSE_MQTT_TLS_KEYSTORE_TYPENoPKCS12Common values: PKCS12, JKS.
GEOPULSE_MQTT_TLS_INSECURE_SKIP_HOSTNAME_VERIFICATIONNofalseDebugging only. Keep false in production.

Certificate/Key Requirements

1) Broker uses public CA cert, no mTLS

Usually no extra files are needed.

  • Set GEOPULSE_MQTT_TLS_ENABLED=true
  • Set broker host/port
  • Leave truststore/keystore paths empty

2) Broker uses private CA or self-signed cert, no mTLS

You need:

  • A truststore containing the broker CA certificate (or broker cert chain)

Set:

  • GEOPULSE_MQTT_TLS_TRUSTSTORE_PATH
  • GEOPULSE_MQTT_TLS_TRUSTSTORE_PASSWORD
  • GEOPULSE_MQTT_TLS_TRUSTSTORE_TYPE

3) Broker enforces mTLS

You need:

  • Truststore (CA for broker validation)
  • Keystore containing client certificate + private key

Set truststore and keystore variables.

Docker Compose: Volume Mounts

If you use truststore/keystore paths, mount these files into geopulse-backend.

Example (docker-compose.yml):

services:
geopulse-backend:
# ... existing configuration ...
volumes:
- ./keys:/app/keys
- ./import-drop:/data/geopulse-import
- ./mqtt-certs:/app/mqtt-certs:ro

Then reference in .env:

GEOPULSE_MQTT_ENABLED=true
GEOPULSE_MQTT_BROKER_HOST=broker.example.com
GEOPULSE_MQTT_BROKER_PORT=8883
GEOPULSE_MQTT_USERNAME=your-mqtt-user
GEOPULSE_MQTT_PASSWORD=your-mqtt-password

GEOPULSE_MQTT_TLS_ENABLED=true
GEOPULSE_MQTT_TLS_PROTOCOL=TLSv1.2

# Private CA / self-signed case
GEOPULSE_MQTT_TLS_TRUSTSTORE_PATH=/app/mqtt-certs/mqtt-truststore.p12
GEOPULSE_MQTT_TLS_TRUSTSTORE_PASSWORD=change-this
GEOPULSE_MQTT_TLS_TRUSTSTORE_TYPE=PKCS12

# mTLS only (leave empty if broker does not require client cert)
GEOPULSE_MQTT_TLS_KEYSTORE_PATH=
GEOPULSE_MQTT_TLS_KEYSTORE_PASSWORD=
GEOPULSE_MQTT_TLS_KEYSTORE_TYPE=PKCS12

Backward Compatibility

Existing configurations continue to work without changes:

  • If GEOPULSE_MQTT_TLS_ENABLED=false (default), GeoPulse uses plain MQTT (tcp://).
  • Built-in GeoPulse Mosquitto deployment remains non-TLS by default.

Troubleshooting

  • Backend fails to start MQTT connection after enabling TLS:
    • Verify truststore/keystore files are mounted into geopulse-backend.
    • Verify paths point to in-container locations.
    • Verify file passwords and store types (PKCS12/JKS).
  • TLS hostname mismatch:
    • Ensure broker certificate CN/SAN matches GEOPULSE_MQTT_BROKER_HOST.
    • Do not disable hostname verification in production.