English
Configure TLS for ThinkLink
Run tkl-tls on the server hosting your Docker installation. Schedule certificate changes during a maintenance window.
1 Download and start
- Complete package: the tool and Chinese/English manuals.
- Command-line package: the command-line tool.
These download addresses remain unchanged. Future releases replace only the files behind these links. Files customers have already downloaded do not update automatically: download again. For an offline server, download on a connected computer and transfer the package.
Extract the latest package, enter the tool directory, and run:
bash
sudo bash tkl-tls.shEnter a hostname covered by the certificate, the full PEM certificate chain file, and the matching unencrypted private-key file. Review the plan and enter YES. The endpoints share the hostname and certificate by default, and WSS/MQTTS use configure mode. Default URLs are shown below; use the actual host ports when mappings differ.
- ThinkLink HTTPS:
https://iot.example.com - EMQX management HTTPS:
https://iot.example.com:18084 - Existing EMQX management HTTP:
http://iot.example.com:18083 - Device WSS:
wss://iot.example.com:8084/mqtt - Device MQTTS:
mqtts://iot.example.com:8883
2 Connection ports
Use port 443 for HTTPS, the /mqtt path on port 8084 for WSS, or port 8883 for MQTTS. Confirm the external address and ports with your administrator.
Existing MQTT and WebSocket endpoints on 1883 and 8083 retain their site settings. The management endpoints use 18083 or 18084.
3 Browser security warnings
An HTTPS certificate must cover the hostname actually used, and its chain must be trusted by the client. Port numbers do not affect hostname matching, so ports 443, 18084, 8084, and 8883 on the same hostname can use one certificate. When sharing a certificate across different hostnames, its SANs must cover them all.
With a self-signed certificate or a certificate issued by a private CA, browsers warn that the connection is unsafe if the client does not trust the CA. First identify the reason: check the hostname, certificate validity, and certificate chain.
In test or controlled intranet environments, install the private CA root certificate in the client's trusted certificate store. For services used by ordinary browser users, use a certificate issued by a publicly trusted CA.
Access the service using a hostname covered by the certificate; do not arbitrarily switch to an IP address. Ignoring browser warnings must not be a normal operating step.
--ca-file only lets the tool verify private-CA certificates. It does not automatically make browsers or devices trust that CA. tkl-tls does not request, issue, or automatically renew certificates. The deployment operator supplies a certificate chain and matching private key, then uses the tool to apply later updates.
4 Commands and port diagnostics
Run port diagnostics without providing certificates:
bash
sudo ./tkl-tls portsThis checks container listeners, actual Docker mappings, and local TCP connectivity for container ports 443, 18083, 18084, 8084, 8883, 1883, and 8083. Missing items produce a nonzero exit code. The command is read-only: it recreates no services and creates no state directory. It does not verify certificates, WSS/MQTTS protocols, or public-network reachability.
| Command | Purpose |
|---|---|
ports | Check current listeners, mappings, and local TCP |
check | Validate certificates and candidate configuration; create candidate files and temporary validation containers without recreating existing services |
apply | Apply configuration and verify the running result |
status | Verify mappings, HTTP, HTTPS certificates, the WSS handshake, and MQTTS TLS/MQTT CONNACK for the saved configuration |
rollback | Restore the preceding deployment configuration while retaining persisted data |
The wizard handles the default setup; check is optional. For command-line configuration, use the following pattern. Replace angle-bracket placeholders with your own file locations before execution; do not type the brackets literally.
text
sudo ./tkl-tls apply --thinklink-domain iot.example.com \
--cert <CERTIFICATE_CHAIN_FILE> --key <PRIVATE_KEY_FILE> \
--wss-mode configure| Option | Purpose |
|---|---|
--thinklink-port | ThinkLink HTTPS host port; default 443 |
--emqx-port | EMQX HTTPS host port; default 18084 |
--emqx-http-port | Host port to add when the mapping for 18083 is missing |
--wss-port | Host port to add when the mapping for 8084 is missing |
--mqtts-port | Host port to add when the mapping for 8883 is missing |
--mqtts-mode configure | Default: manage the MQTTS listener and certificate |
--mqtts-mode preserve | At first adoption, retain the existing MQTTS listener and certificate, add missing mappings, and verify |
--wss-mode configure | Default: manage the WSS listener, path, and certificate with the tool |
--wss-mode preserve | Preserve the existing WSS listener configuration, add missing mappings, and verify |
--emqx-domain | A separate EMQX hostname, such as emqx.example.com |
--emqx-cert, --emqx-key | A separate EMQX certificate and key; supply both |
--ca-file | Private CA file used by the tool for verification |
Existing HTTP/WSS/MQTTS mappings are retained by default. The five managed host ports must be distinct and must not belong to other services. A supplied value that conflicts with an existing mapping stops the operation with a message. When host ports change, update URLs, client settings, and network access rules. Retain custom Compose, service-name, and state-directory options in later operations.
5 WSS configuration and the Web interface
Manage WSS with the tool by default
The new default, --wss-mode configure, configures the native EMQX WSS listener on 8084, the /mqtt path, and the EMQX certificate supplied for this operation. Existing authentication, authorization, and client-certificate verification policies are preserved.
In this mode, use tkl-tls for subsequent certificate updates. These fields written to emqx.conf take precedence over Web changes after restart. Uploading a WSS certificate through Web is not part of the default setup.
Continue managing WSS through Web
To retain Web management, use --wss-mode preserve on the first application:
text
sudo ./tkl-tls apply --thinklink-domain iot.example.com \
--cert <CERTIFICATE_CHAIN_FILE> --key <PRIVATE_KEY_FILE> \
--wss-mode preserveThis preserves the listener configuration, adds missing mappings, and verifies it. WSS must already listen on container port 8084 at /mqtt. Its certificate must cover the EMQX hostname and be trusted by the system or the CA supplied with --ca-file. For a private CA, add --ca-file <CA_FILE> to the command.
In EMQX management, open Management → Listeners. The actual English EMQX 5.8.8 screenshot below shows the default row with type wss and port 8084. Do not select the ssl 8883 row to configure WSS.

In configure mode, use this page to inspect the WSS listener; update certificates through the tool. In preserve mode, the operator maintains the existing WSS certificate, path, and verification policy through Web, then verifies using the tool's application or status. Web does not replace Docker mappings or network access rules.
The current protocol probe sends no client certificate. It cannot perform WSS mutual-TLS acceptance when client certificates are required. The tool does not disable mutual TLS to make checks pass.
Manage MQTTS 8883 by default
In 2.2.0, the default --mqtts-mode configure manages the ssl 8883 listener, the EMQX certificate, and missing Docker mappings. MQTTS, WSS, and management HTTPS share the supplied EMQX certificate by default. Existing authentication, authorization, and client-certificate requirements are retained. Higher-priority WSS/MQTTS environment overrides are rejected.
At first adoption, --mqtts-mode preserve retains an existing MQTTS listener and certificate. Container port 8883 must already listen; the certificate must be trusted and cover the EMQX hostname. The tool still adds missing mappings and verifies TLS and the MQTT response. Switching tool-managed MQTTS from configure to preserve requires rollback first to avoid silently restoring old settings.
The screenshot below shows the ssl certificate fields maintained by the operator in preserve mode. With the default configure mode, renew through the tool instead of uploading certificates through Web. The Web interface cannot change Docker mappings or security-group rules.

Empty fields are not a completed configuration. Select the certificate and matching key from the computer running the browser, complete the fields, resolve errors before saving, and verify device authentication and messaging.
6 Certificate updates and rollback
bash
sudo ./tkl-tls statusAfter obtaining a new certificate, apply it with the tool:
text
sudo ./tkl-tls apply --cert <NEW_CERTIFICATE_CHAIN_FILE> \
--key <NEW_PRIVATE_KEY_FILE>Saved hostnames and ports are retained. Supply --ca-file again for a private CA. Supply both --emqx-cert and --emqx-key again for a separate EMQX certificate; otherwise EMQX shares the new ThinkLink certificate. In the default configure mode, EMQX management HTTPS, WSS, and MQTTS use the supplied EMQX certificate and share certificate renewal and rollback. In preserve mode, maintain the corresponding listener certificate through its existing management method. Renewal inherits the saved management modes.
To undo the preceding deployment:
bash
sudo ./tkl-tls rollbackInitial application, certificate updates, and rollback briefly recreate ThinkLink and EMQX. The tool retains current images and existing data volumes and handles persistence of the actual EMQX data directory. Rollback retains persisted data. Protect the tool's state directory; do not delete it or publish it as a log bundle. Do not delete or prune volumes to troubleshoot TLS.
7 Acceptance and FAQ
Passing local checks does not prove public-network reachability. After application, verify from the client network:
- ThinkLink HTTPS and an actual login.
- EMQX HTTPS and an actual login.
- WSS and MQTTS authentication, subscriptions, publishing, and reconnection.
- Security groups, firewalls, DNS, and client certificate trust.
Application and status verify MQTTS TLS and MQTT 3.1.1 CONNACK with a temporary clean session, no credentials, no will, and no publish. Authentication refusal codes 4/5 prove protocol availability only, not account authentication. The current probe sends no client certificate and does not support WSS/MQTTS mutual-TLS acceptance; the tool never disables mutual TLS.
For public access, check DNS, host binding addresses, Docker mappings, cloud security groups, and the host firewall, then use the actual hostname from another machine. Allow the actual host ports, including custom mappings. Port 18083 remains plaintext management HTTP with its existing access restrictions; management HTTPS uses 18084. The tool does not change security groups, DNS, or firewall rules.
A successful WSS handshake or MQTTS protocol check does not prove device authentication or message delivery. Existing loopback-only mappings remain local-only; the tool does not automatically widen access.
| Question | Action or answer |
|---|---|
| Do old downloads update automatically? | No. Download the latest package again from the same links |
| Why is 18083 still HTTP? | The original HTTP service is retained; management HTTPS uses 18084 |
| A mapped port is unreachable | Use ports to check listeners, mappings, and local TCP, then check the client network |
| The browser warns the connection is unsafe | Check hostname, validity, chain, and client trust; do not make bypassing warnings a normal step |
| Web WSS certificate changes revert after restart | configure fields take precedence; update through the tool or choose preserve at first application |
| Port occupation or configuration conflict | Resolve the reported conflict before retrying; other services are not overwritten |
| Are endpoints deleted after checking? | Successfully applied configuration and endpoints remain; temporary check containers are not the business endpoints |
Users of 2.0/2.1 can run the new tool with apply, retaining the original state directory and adding 8883 support by default. The new tool reads older states. Upgrade rollback restores the previous mappings and configuration, removing a newly added 8883 mapping if none existed before. Persisted data is retained; databases are not downgraded, and the old tool can read the restored old state.
After an interrupted operation, follow the tool's recovery instructions and roll back when requested. Coordinate existing Compose changes rather than overwriting them. For an Existing installations, use its old rollback to release ports before migrating; do not reuse the old gateway state.