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

TLS self signed certificate python error #682

Closed Balaji-schnell closed 2 years ago

Balaji-schnell commented 2 years ago

i have used these commands to generate server.pem ( self signed certificate ) and server_key.pem (privarte key) openssl ecparam -out server_key.pem -name secp256r1 -genkey openssl req -new -key server_key.pem -x509 -nodes -days 365 -out server.pem

and the server running fine In client side used below cmds to get client certificate and private key

openssl ecparam -out key.pem -name secp256r1 -genkey openssl req -new -key key.pem -x509 -nodes -days 365 -out cert.pem

In python

client.tls_set(ca_certs="server.pem", certfile="cert.pem ", keyfile="key.pem", cert_reqs=ssl.CERT_NONE,tls_version=ssl.PROTOCOL_TLSv1_2, ciphers=None);

client.tls_insecure_set(False) client.connect("XXXXXXXX", 8883, 60)

Error:

ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] self signed certificate (_ssl.c:1131)

Configuration

In thingsboard.conf

export MQTT_SSL_ENABLED=true export MQTT_SSL_BIND_ADDRESS=0.0.0.0 export MQTT_SSL_BIND_PORT=8883 export MQTT_SSL_CREDENTIALS_TYPE=PEM export MQTT_SSL_PEM_CERT=/etc/thingsboard/conf/server.pem export MQTT_SSL_PEM_KEY=/etc/thingsboard/conf/server_key.pem export MQTT_SSL_PEM_KEY_PASSWORD=password **

Versions (please complete the following information):

samson0v commented 2 years ago

Hi @Balaji-schnell, I think your issue is related to ThingsBoard, but not to Gateway. Also, I think that the way you generate your certificate is wrong.