Skip to content

SolaceServices/Python-MQTT-mTLS-demo

Repository files navigation

Solace MQTTS Python Demo

A robust, containerized Python demonstration for connecting to Solace PubSub+ Cloud. This project provides indepedent examples for Basic Authentication and mTLS (Client Certificate) Authentication.

Prerequisites

  1. Solace PubSub+ Cloud Account: You need a running service.
  2. Docker Desktop: Installed and running.

Credentials Setup

  1. Copy the example: cp .env.example .env
  2. Fill in your details from Solace Cloud "Connect" tab.

How to Run

1. Build the Docker Image

docker build -t solace-demo-app .

2. Run Subscriber (Basic Auth)

Connects using Username/Password and listens for messages.

docker run --env-file .env -it --rm solace-demo-app python subscriber.py

3. Run Publisher (Basic Auth)

This script publisher.py uses Username and Password from .env.

docker run --env-file .env -it --rm solace-demo-app python publisher.py

4. Run Publisher (mTLS / Client Cert)

This script publisher_mtls.py uses Client Certificates and ignores the password.

  1. Generate Certs: See CERTIFICATES.md.
  2. Mount Certs:
docker run -v $(pwd)/certs:/certs --env-file .env -it --rm solace-demo-app python publisher_mtls.py

Note: This script prints Auth: Client Certificate (No Password) to confirm it is not using the password field.

Key Technical Features

  • Totally Independent Scripts: publisher.py and publisher_mtls.py share no code, demonstrating the distinct verification methods.
  • Paho MQTT v2: Uses the latest library version.
  • Containerized: Runs anywhere Docker runs.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors