Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New entry: Connect to an MQTT broker with TLS encryption #67

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

TotallyInformation
Copy link

Copy link

@skleeschulte skleeschulte left a comment

Choose a reason for hiding this comment

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

The image images/mqtt/tls-connect-1.png shows using an mqtts://-URL without selecting Enable secure (SSL/TLS) connection, which in the current version of Node-RED effectively disables validation of the server certificate (see node-red#2379).

Copy link

@skleeschulte skleeschulte left a comment

Choose a reason for hiding this comment

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

Maybe this article could be improved by separating three things:

  1. How to set up Node-RED to connect to an MQTT broker using SSL/TLS: Using a server URL starting with mqtts:// (or tls://, see https://www.npmjs.com/package/mqtt#mqttconnecturl-options), enabling server certificate verification, optionally supplying CA certificate(s).

  2. How to set up Mosquitto to allow for SSL/TLS connections, maybe showcasing it for a specific environment.

  3. Additional information about using Let's Encrypt certificates.

mqtt/tls-connect-to-broker.md Outdated Show resolved Hide resolved
mqtt/tls-connect-to-broker.md Show resolved Hide resolved
mqtt/tls-connect-to-broker.md Show resolved Hide resolved
mqtt/tls-connect-to-broker.md Outdated Show resolved Hide resolved
mqtt/tls-connect-to-broker.md Outdated Show resolved Hide resolved
mqtt/tls-connect-to-broker.md Outdated Show resolved Hide resolved
mqtt/tls-connect-to-broker.md Show resolved Hide resolved
@TotallyInformation
Copy link
Author

Thanks for all the comments. PR now updated.

Copy link

@Paul-Reed Paul-Reed left a comment

Choose a reason for hiding this comment

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

Looks good to me Julian!
Thanks for documenting.

mqtts://broker.domain.tld:9999
```

* You **do not** need to set the "Enable secure connection" flag unless you want to authenticate the Node-RED client to the broker (if you set the require_certificate to true for example).

Choose a reason for hiding this comment

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

I think this line is still misleading, or at least prominently advertising a configuration where the server certificate is not validated. In the context of this article about encrypted connections, the note that the "Enable secure connection" flag is only relevant for authenticating clients looks even wrong to me, in two regards:
(1) The flag and the TLS configuration it reveals are relevant for both, the TLS connection and the certificate based user authentication. The article explicitly mentions self-signed certificates, and to validate these, they must be configured here.
(2) The flag is not necessary for user authentication that is not certificate based.


Notes

* You need to use the IP name rather than IP address in the server name if using Let's Encrypt (otherwise the certificate isn't valid).

Choose a reason for hiding this comment

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

IP name -> domain name?
More specific: If using a Let's Encrypt certificate, one needs to use the domain name the certificate was issued for.

Notes

* You need to use the IP name rather than IP address in the server name if using Let's Encrypt (otherwise the certificate isn't valid).
* You need to change the server name to a url, prefixed with `mqtts://`.

Choose a reason for hiding this comment

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

In fact, this is not necessary when enabling the "Enable secure connection" flag, which needs to be enabled to have the server certificate verified.

@@ -0,0 +1,128 @@
---
layout: default
title: Connect to an MQTT broker with TLS encryption

Choose a reason for hiding this comment

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

Reading this title in the Node-RED cookbook, I would expect more information about how to configure the mqtt-broker node for secure connections (e.g. clarification of the meanings of the fields in the TLS configuration dialog, usage of self signed certificates including validation) and not necessarily information about configuring the MQTT broker.

Maybe instead: "Set up the Mosquitto MQTT broker to accept encrypted connections and connect to it from Node-RED"? Or add more information about the configuration options in Node-RED?


Create a valid set of certificates and keys for the broker to use.

Change the configuration of the broker to start a TLS encrypted port (`mqtts`) using the above.

Choose a reason for hiding this comment

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

Maybe "... to accept encrypted connections..." instead of "...to start a TLS encrypted port..."?

mqtt/tls-connect-to-broker.md Show resolved Hide resolved

**<code class="node">MQTT Config</code> node configuration**

![](/images/mqtt/tls-connect-1.png)

Choose a reason for hiding this comment

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

This image shows a configuration where the certificate is not validated.

* You need to use the IP name rather than IP address in the server name if using Let's Encrypt (otherwise the certificate isn't valid).
* You need to change the server name to a url, prefixed with `mqtts://`.

This disables the port field, I change that first to `8883` to remind me what the correct port will be.

Choose a reason for hiding this comment

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

Another advantage of ticking the "Enable secure connection" checkbox: Because there is no need to add the protocol to the Server field, the port field stays enabled.

mqtt/tls-connect-to-broker.md Show resolved Hide resolved
mqtt/tls-connect-to-broker.md Show resolved Hide resolved
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.

4 participants