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!
-
ssl_paramsis 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
strI guess):ssl_params= {'cert_reqs':ssl.CERT_REQUIRED, 'ca_certs':'pycom/ca.pem'}https://docs.python.org/3/tutorial/datastructures.html#dictionaries
-
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?
-
@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
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login