Open IhorYednak opened 4 days ago
hey @IhorYednak!
Thank you for reaching out! To resolve the issue, you can generate a self-signed certificate and mount it into the Docker container using bind mounts from a directory on the host machine. Once the certificate is available inside the container, you need to configure the appropriate environment variables to point to the certificate and private key. These steps will enable TBMQ to use the self-signed certificate for TLS.
For more details: https://thingsboard.io/docs/mqtt-broker/security/ https://docs.docker.com/engine/storage/bind-mounts/ https://thingsboard.io/docs/user-guide/mqtt-over-ssl/#self-signed-certificates-generation
Let us know if you need further assistance!
Thank you for your reply @dmytro-landiak In case I already have a certificate, if I move it into the directory with the config files for tbmq, and configure the passwords and path to it in tbmq.conf file, will it work?
You can try that but this is not recommended.
Better use the below approach (note, the example here uses server.pem
and server_key.pem
with no password):
...
tbmq:
restart: always
image: "thingsboard/tbmq:2.0.0"
...
environment:
TB_SERVICE_ID: tbmq
...
LISTENER_SSL_ENABLED: true
LISTENER_SSL_PEM_CERT: /ssl/server.pem
LISTENER_SSL_PEM_KEY: /ssl/server_key.pem
#JAVA_OPTS: "-Xmx2048M -Xms2048M -Xss384k -XX:+AlwaysPreTouch"
volumes:
- tbmq-logs:/var/log/thingsboard-mqtt-broker
- tbmq-data:/data
- PUT_THE_PASS_TO_CERTIFICATE_HERE_ON_HOST_MACHINE:/ssl
...
So you mean to use the docker-compose.yml instead of conf, correct?
yes, you understood this correctly
And about the path, does it specify here the path inside a container where tbmq running, or the path inside a VM?
It is the path inside the container. So, the path from the end of the next line + the name of the files
volumes:
- PUT_THE_PASS_TO_CERTIFICATE_HERE_ON_HOST_MACHINE:**/ssl**
This is how I made it:
But still I can't see variable TLS Listener is Enabled
Steps I did: openssl ecparam -out server_key.pem -name secp256r1 -genkey openssl req -new -key server_key.pem -x509 -nodes -days 365 -out server.pem copied server.pem and server_key.pem to etc/ssl/certs at VM Provided access to files chmod 644 /path/to/certificates/* for all files inside a certs folder No clue what else could do the trick :(
Please, add SECURITY_MQTT_SSL_ENABLED
env to the docker-compose file with the value true
.
Please, read the next doc: https://thingsboard.io/docs/mqtt-broker/security/#tls-listener
In addition, you have wrongly set LISTENER_SSL_PEM_CERT
and so on.
In your case, it should be
LISTENER_SSL_PEM_CERT: /etc/ssl/certs/server.pem
But I recommend using another folder.
Hello @dmytro-landiak
Can you advise on how to proper use the SSL certificate at TBMQ. I was able to get to the etc/ssl/certs in the docker tbmq image. However when I ran ls command I was flashed with a lot of files. Would you be able to help me to clarify what certificate should I use for SSL and how to proper define it in the docker-compose.yml file?
Attached is the screenshot of what I see here
Also here is the copy of docker-compose.yml
` Copyright © 2016-2024 The Thingsboard Authors
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and imitations under the License.
version: "3.0" services: postgres: restart: always image: "postgres:15" ports:
JAVA_OPTS: "-Xmx2048M -Xms2048M -Xss384k -XX:+AlwaysPreTouch"
volumes:
volumes: tbmq-postgres-data: external: true tbmq-kafka-data: external: true tbmq-logs: external: true tbmq-data: external: true`
Will appreciate any kind of help Thank you in advance!