Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    Using MQTT with SSL on Lopy

    Scheduled Pinned Locked Moved LoPy
    mqttssl
    4 Posts 3 Posters 2.2k Views 4 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A Offline
      achide
      last edited by

      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!

      1 Reply Last reply Reply Quote 0
      • S Offline
        sakis
        last edited by

        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

        G 1 Reply Last reply Reply Quote 0
        • A Offline
          achide
          last edited by

          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?

          1 Reply Last reply Reply Quote 0
          • G Offline
            grovalmitch @sakis
            last edited by

            @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#dictionaries

            More on...Python dictionary

            1 Reply Last reply Reply Quote 0

            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
            • 1 / 1
            • First post
              Last post

            Pycom on Twitter

            Pycom