Skip to content
Stand with Ukraine flag

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.

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/:

Terminal window
sudo mkdir -p /etc/thingsboard/conf/certs
cd /etc/thingsboard/conf/certs
  1. Generate a private key:

    Terminal window
    sudo openssl genpkey -algorithm RSA -out privateKey.pem -pkeyopt rsa_keygen_bits:2048

    This creates a 2048-bit RSA private key stored in privateKey.pem.

  2. Generate a Certificate Signing Request (CSR):

    Terminal window
    sudo openssl req -new -key privateKey.pem -out certRequest.csr

    Provide your organization name, common name (domain name), and email address when prompted.

  3. 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 365

    Adjust -days to change the validity period. An expired certificate breaks all Edge connections silently — plan for renewal before expiry.

  4. Enable SSL on the ThingsBoard server. For Ubuntu and CentOS/RHEL installations:

    Terminal window
    sudo sh -c 'cat <<EOL >> /etc/thingsboard/conf/thingsboard.conf
    export EDGES_RPC_SSL_ENABLED=true
    export EDGES_RPC_SSL_CERT=/etc/thingsboard/conf/certs/certFile.crt
    export EDGES_RPC_SSL_PRIVATE_KEY=/etc/thingsboard/conf/certs/privateKey.pem
    EOL'
  5. Restart the server to apply the changes:

    Terminal window
    sudo systemctl restart thingsboard

    Confirm SSL is active by checking the server logs:

    Terminal window
    sudo journalctl -u thingsboard -n 50 | grep -i ssl

    Look for a line confirming that the gRPC server started with SSL enabled.

After configuring the server, enable SSL on the Edge side to match.

  1. Enable SSL communication on the Edge:

    Terminal window
    sudo sh -c 'cat <<EOL >> /etc/tb-edge/conf/tb-edge.conf
    export CLOUD_RPC_SSL_ENABLED=true
    EOL'
  2. 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.crt

    Replace username and server_ip with 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.conf
    export CLOUD_RPC_SSL_CERT=/etc/tb-edge/conf/certFile.crt
    EOL'
  3. Restart Edge to apply the changes:

    Terminal window
    sudo systemctl restart tb-edge
  4. Verify the TLS connection was established:

    Terminal window
    sudo journalctl -u tb-edge -n 100 | grep -i ssl

    Look 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.