Skip to content

Add very basic example for mqtt tls#458

Merged
dpgeorge merged 1 commit into
micropython:masterfrom
mrkeuz:mqtt-tls-example
Jun 30, 2026
Merged

Add very basic example for mqtt tls#458
dpgeorge merged 1 commit into
micropython:masterfrom
mrkeuz:mqtt-tls-example

Conversation

@mrkeuz

@mrkeuz mrkeuz commented Oct 29, 2021

Copy link
Copy Markdown
Contributor

Tested on next setup:

  • MicroPython 1.17 (without ca-cert's)
  • Traefik Proxy 2.5 (Let's Encrypt Cert)
  • Mosquitto 2.0.12

Note:

  • Unable connect without ssl_params = {"server_hostname": "<addr>"}

  • If keepalive = 0 (default) got MQTTException(2)

  • Don't found ssl.CERT_XXX or ussl.CERT_XXX constants,
    although the constants are specified in the documentation.
    Only found in inner definitions. But didn't understand how use it outside:

    for sym in "CERT_NONE", "CERT_OPTIONAL", "CERT_REQUIRED":
    if sym not in globals():
    globals()[sym] = object()

    Not sure if all of this is bad defaults or this behavior made by design.

@JayPalm

JayPalm commented Jan 9, 2023

Copy link
Copy Markdown

Thanks for this PR! Adding the ssl_params seemed to be the magic required to get a working connection with a HiveMQ broker.

@dpgeorge dpgeorge left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, and sorry this took forever to review.

I tested it with mosquitto in TLS mode and it worked.

Signed-off-by: Damien George <damien@micropython.org>
@dpgeorge dpgeorge merged commit d966d76 into micropython:master Jun 30, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants