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 ='192.168.0.103', 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!
-
@sakis said in Using MQTT with SSL on Lopy:
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'}
https://docs.python.org/3/tutorial/datastructures.html#dictionariesMore on...Python dictionary
-
Hi,
You're right! Thank you.
But I have another error, it told me :
OSError: certificate file not foundIt'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'}
https://docs.python.org/3/tutorial/datastructures.html#dictionaries