Using MQTT with SSL on Lopy

  • Hello,

    I recently started MQTT on Lopy, I've followed the tutoriel on youtube. And I successfully connect with broker.
    Now I would like to use SSL with MQTT, but I haven't find any description of this part.
    Here's my code:
    client = MQTTClient('Lopy', server ='', port =8883,ssl = True, ssl_params= {cert_reqs=ssl.CERT_REQUIRED, ca_certs = 'pycom/ca.pem', keyfile = 'pycom/client1key.pem', certfile= 'pycom/client1.pem'})
    And I got error in this line.
    I'm not sure but I think ssl_params is not in rignt format.
    If someone can help me?

    Thanks a lot!

  • Hi,

    You're right! Thank you.
    But I have another error, it told me :
    OSError: certificate file not found

    It's right that I use pem files?

  • ssl_params is a dict. You shouldn't use = to assign values to dict keys, but :

    Also, a key should be a valid Python type (in this case str I guess):

    ssl_params= {'cert_reqs':ssl.CERT_REQUIRED, 'ca_certs':'pycom/ca.pem'}

Log in to reply

Looks like your connection to Pycom Forum was lost, please wait while we try to reconnect.