thingsboard / thingsboard-gateway

Open-source IoT Gateway - integrates devices connected to legacy and third-party systems with ThingsBoard IoT Platform using Modbus, CAN bus, BACnet, BLE, OPC-UA, MQTT, ODBC and REST protocols
https://thingsboard.io/docs/iot-gateway/what-is-iot-gateway/
Apache License 2.0
1.72k stars 829 forks source link

[HELP] connect MQTT to AWS IOT #497

Closed t0mZ4 closed 3 years ago

t0mZ4 commented 3 years ago

Hi there

I am trying to connect mqtt connector to AWS IOT

here is my config file:


{
  "broker": {
    "name":"Default Local Broker",
    "host":"xxxx-ats.iot.eu-central-1.amazonaws.com",
    "port":8883,
    "clientId": "SmartSignalsCE",
  "security":{
    "caCert": "/etc/thingsboard-gateway/awsca.pem",
    "privateKey": "/etc/thingsboard-gateway/8106d39303-private.pem.key.pem",
    "cert": "/etc/thingsboard-gateway/8106d39303-certificate.pem.crt"
  }    

This is the error I am getting:


""2021-03-29 15:01:48" - ERROR - [mqtt_connector.py] - mqtt_connector - 112 - Cannot setup connection to broker MQTT Broker Connector using SSL. Please check your configuration.
Error: "
""2021-03-29 15:01:48" - ERROR - [mqtt_connector.py] - mqtt_connector - 113 - [SSL] PEM lib (_ssl.c:3524)"
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/thingsboard_gateway/connectors/mqtt/mqtt_connector.py", line 108, in __init__
    ciphers=None)
  File "/usr/local/lib/python3.6/dist-packages/paho/mqtt/client.py", line 823, in tls_set
    context.load_cert_chain(certfile, keyfile)
ssl.SSLError: [SSL] PEM lib (_ssl.c:3524)

any idea? using latest release

t0mZ4 commented 3 years ago

I added this to the config:

"ssl": true

{
  "broker": {
    "name":"Default Local Broker",
    "host":"xxx-ats.iot.eu-central-1.amazonaws.com",
    "port":8883,
    "clientId": "SmartSignalsCE",
    "ssl": true,
  "security":{
    "caCert": "/etc/thingsboard-gateway/config/awsca.pem",
    "privateKey": "/etc/thingsboard-gateway/config/key.pem",
    "cert": "/etc/thingsboard-gateway/config/cert.pem"
  }    

now I get this error not found, I think it is not finding the certs, but I am doing it pretty straight forward


Error: "
""2021-03-29 19:28:01" - ERROR - [mqtt_connector.py] - mqtt_connector - 113 - [Errno 2] No such file or directory"
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/thingsboard_gateway/connectors/mqtt/mqtt_connector.py", line 108, in __init__
    ciphers=None)
  File "/usr/local/lib/python3.6/dist-packages/paho/mqtt/client.py", line 823, in tls_set
    context.load_cert_chain(certfile, keyfile)
FileNotFoundError: [Errno 2] No such file or directory
t0mZ4 commented 3 years ago

ok well it turns out the certs must be in /etc/thingsboard-gateway/ and no where else and I think adding "ssl": true to the broker config is required as well.

closing da ticket.