Search code examples
pythonx509certificatethingsboard

Connecting with Thingsboard using X.509 certificate


I have been trying to connect my Python simulator with thingsboard. I tried using Access Tokens and it worked but now I'm trying to connect with X.509 certificates. There is not much help available over internet and their documentation seems like outdated. Can anyone help me with the connection?

EDIT 1

I'm following this documentation https://thingsboard.io/docs/paas/user-guide/certificates/. I downloaded

tb-cloud-chain.pem

key.pem

cert.pem

Now on running test command using mosquitto_pub, I'm getting this error, enter image description here


Solution

  • After hit and trail, I was able to solve the error,

    client = mqtt.Client()
    client.tls_set(ca_certs=certficates["CA_File"], certfile=certficates["Cert_File"], keyfile=certficates["Key_File"],
                   tls_version=ssl.PROTOCOL_TLSv1_2)
    client.tls_insecure_set(False)
    client.connect(host_name, 8883, 1)
    print("connect success")
    client.loop_start()
    client.publish('v1/devices/me/telemetry', json.dumps(schema), 1)
    

    CA_File is the chain file I downloaded from this link Cert_File and Key_Files are downloaded using openssl commands mentioned in this link