Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Ngrok will provide a public URL ( like tcp://0666.tcp.ngrok.io:XXXXX) that forwards to your local machine's port 8883.

Note

Each time ngrok starts it will provide a different URL and port. In this article, we use 0666.tcp.ngrok.io:XXXXX as an example. In your case, the hostname and port will be different.

Use your Ngrok URL (0666.tcp.ngrok.io:XXXXX) in place of the hostname and port when configuring your IoT device or client.

...

Generate a self-signed server certificate (replace 0666.tcp.ngrok.io with your domain)

Code Block
languagebash
openssl req -new -newkey rsa:2048 -days 365 -nodes -x509 -keyout server.key -out server.crt -subj "/CN=0666.tcp.ngrok.io"
  • Generates a self-signed server certificate (server.crt) and private key (server.key) valid for 365 days.

  • The -subj "/CN=0666.tcp.ngrok.io" option sets the Common Name (CN) in the certificate to 0666.tcp.ngrok.io. Replace 0666.tcp.ngrok.io with your domain name or IP address.

...

Test device connection to hostname 0666.tcp.ngrok.io port XXXXX

Testing with MQTT-CLI

...

Code Block
languagebash
mqtt publish --topic Test --message Hello --host 0666.tcp.ngrok.io --port XXXXX --cafile server.crt --debug

...

Connect your IoT device or client to the local TLS server. Observe the output from the OpenSSL server. Look for the ClientHello packet in the debug output, which indicates if TLS-SNI is being used and the hostname (0666.tcp.ngrok.io in this case) the client is requesting.

...