...
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 |
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 | ||
---|---|---|
| ||
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 to0666.tcp.ngrok.io
. Replace0666.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 | ||
---|---|---|
| ||
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.
...