- SSL configuration using PEM certificates file
- Self-signed certificates generation
- Client Examples
ThingsBoard provides the ability to run HTTP server that process API calls from devices over SSL. This guide is effectively the copy of Enable HTTPS guide.
Most of the ThingsBoard environments use the load balancer as a termination point for the SSL connection between the device and the platform. In other words, internet traffic is encrypted between the device and the load balancer, but is decrypted between the load balancer and platform services. The advantage of such options is a simple configuration. Most of the cloud load balancers (AWS, Google cloud, etc) have built-in certificate generation tools and rich documentation how to configure SSL.
Nevertheless, it is possible to configure ThingsBoard to enable SSL and avoid SSL termination on the Load Balancer. We recommend to use valid SSL certificates generated using trusted CA authorities and avoid spending time on resolving issues with self-signed certificates. See instructions below on how to configure SSL for certificates stored in PEM file format or Java Keystore.
SSL configuration using PEM certificates file
|Available since TB Version 3.3.2
Configure the following environment variables via configuration file, docker-compose or kubernetes scripts. We will use thingsboard.conf for example:
- SSL_ENABLED - Enable/disable SSL support;
- SSL_CREDENTIALS_TYPE - Server credentials type. PEM - pem certificate file; KEYSTORE - java keystore;
- SSL_PEM_CERT - Path to the server certificate file. Holds server certificate or certificate chain, may also include server private key;
- SSL_PEM_KEY - Path to the server certificate private key file. Optional by default. Required if the private key is not present in server certificate file;
- SSL_PEM_KEY_PASSWORD - Optional server certificate private key password.
After completing the setup, start or restart the ThingsBoard server.
Self-signed certificates generation
Use instructions below to generate your own certificate files. Useful for tests, but time consuming and not recommended for production.
PEM certificate file
Note This step requires Linux based OS with openssl installed.
To generate a server self-signed PEM certificate and private key, use the following command:
openssl ecparam -out server_key.pem -name secp256r1 -genkey
openssl req -new -key server_key.pem -x509 -nodes -days 365 -out server.pem
You can also add -nodes (short for no DES) if you don’t want to protect your private key with a passphrase. Otherwise, it will prompt you for “at least a 4 character” password.
The days parameter (365) you can replace with any number to affect the expiration date. It will then prompt you for things like “Country Name”, but you can just hit Enter and accept the defaults.
Add -subj ‘/CN=localhost’ to suppress questions about the contents of the certificate (replace localhost with your desired domain).
Self-signed certificates are not validated with any third party unless you import them to the browsers previously. If you need more security, you should use a certificate signed by a certificate authority (CA).
See Access Token based authentication for example of one-way SSL connection.