gRPC over TLS/SSL
By default, the gRPC connection between ThingsBoard Edge and the server is unencrypted. Enabling TLS/SSL secures this channel against interception and tampering. Configuration is split into two parts: the server side and the Edge side — both must be completed for the connection to work.
Server configuration
Section titled “Server configuration”Choose how SSL termination is handled on the server — either using the built-in certificate mechanism or delegating termination to an external load balancer.
The built-in mechanism uses self-signed certificates generated with OpenSSL. This approach is suitable for testing but is not recommended for production environments.
Run all certificate generation commands on the ThingsBoard server. Store the generated files in a dedicated directory, for example /etc/thingsboard/conf/certs/:
sudo mkdir -p /etc/thingsboard/conf/certscd /etc/thingsboard/conf/certs-
Generate a private key:
Terminal window sudo openssl genpkey -algorithm RSA -out privateKey.pem -pkeyopt rsa_keygen_bits:2048This creates a 2048-bit RSA private key stored in
privateKey.pem. -
Generate a Certificate Signing Request (CSR):
Terminal window sudo openssl req -new -key privateKey.pem -out certRequest.csrProvide your organization name, common name (domain name), and email address when prompted.
-
Generate a self-signed certificate valid for 365 days:
Terminal window sudo openssl x509 -req -in certRequest.csr -signkey privateKey.pem -out certFile.crt -days 365Adjust
-daysto change the validity period. An expired certificate breaks all Edge connections silently — plan for renewal before expiry. -
Enable SSL on the ThingsBoard server. For Ubuntu and CentOS/RHEL installations:
Terminal window sudo sh -c 'cat <<EOL >> /etc/thingsboard/conf/thingsboard.confexport EDGES_RPC_SSL_ENABLED=trueexport EDGES_RPC_SSL_CERT=/etc/thingsboard/conf/certs/certFile.crtexport EDGES_RPC_SSL_PRIVATE_KEY=/etc/thingsboard/conf/certs/privateKey.pemEOL' -
Restart the server to apply the changes:
Terminal window sudo systemctl restart thingsboardConfirm SSL is active by checking the server logs:
Terminal window sudo journalctl -u thingsboard -n 50 | grep -i sslLook for a line confirming that the gRPC server started with SSL enabled.
The recommended approach for production is to delegate SSL termination to an external load balancer such as HAProxy. This keeps certificate management outside the ThingsBoard process and scales better in clustered deployments.
For Ubuntu and CentOS/RHEL Server, see Step 6: Configure Edge TLS communication in the HAProxy installation guide.
Edge configuration
Section titled “Edge configuration”After configuring the server, enable SSL on the Edge side to match.
-
Enable SSL communication on the Edge:
Terminal window sudo sh -c 'cat <<EOL >> /etc/tb-edge/conf/tb-edge.confexport CLOUD_RPC_SSL_ENABLED=trueEOL' -
If you are using self-signed certificates, transfer the server’s public certificate to the Edge device:
Terminal window scp username@server_ip:/etc/thingsboard/conf/certs/certFile.crt /etc/tb-edge/conf/certFile.crtReplace
usernameandserver_ipwith your server credentials. Then add the certificate path to the Edge configuration:Terminal window sudo sh -c 'cat <<EOL >> /etc/tb-edge/conf/tb-edge.confexport CLOUD_RPC_SSL_CERT=/etc/tb-edge/conf/certFile.crtEOL' -
Restart Edge to apply the changes:
Terminal window sudo systemctl restart tb-edge -
Verify the TLS connection was established:
Terminal window sudo journalctl -u tb-edge -n 100 | grep -i sslLook for a line confirming that the gRPC channel connected with SSL. If you see SSL handshake errors, confirm the certificate’s common name matches the server’s hostname.
-
Copy
certFile.crtfrom the server to the Edge device:Terminal window scp username@server_ip:/etc/thingsboard/conf/certs/certFile.crt /path/to/certs/certFile.crtReplace
username,server_ip, and the destination path with your actual values. -
Open
docker-compose.ymland add the following to theenvironmentblock:CLOUD_RPC_SSL_ENABLED: "true"CLOUD_RPC_SSL_CERT: "/etc/tb-edge/certs/certFile.crt"Omit
CLOUD_RPC_SSL_CERTif you are using a CA-signed certificate — it is only required for self-signed certificates.Add a volume entry to mount the certificate into the container:
volumes:- /path/to/certs/certFile.crt:/etc/tb-edge/certs/certFile.crt -
Restart the Edge container:
Terminal window docker compose restart mytbedge -
Verify the TLS connection was established:
Terminal window docker logs mytbedge 2>&1 | grep -i sslLook for a line confirming that the gRPC channel connected with SSL. If you see SSL handshake errors, confirm the certificate’s common name matches the server’s hostname.