<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[[solved] MQTT and tls]]></title><description><![CDATA[<p dir="auto">Hello there,</p>
<p dir="auto">I have to use mqtt over tls connection.<br />
right now I am using <a href="https://github.com/micropython/micropython-lib/tree/master/umqtt.simple" target="_blank" rel="noopener noreferrer nofollow">simple mqtt lib</a><br />
Can you recommend me a library, or some code snippet? So far googleing doesn't brought me any luck</p>
]]></description><link>https://forum.pycom.io/topic/4775/solved-mqtt-and-tls</link><generator>RSS for Node</generator><lastBuildDate>Thu, 11 Jun 2026 18:50:33 GMT</lastBuildDate><atom:link href="https://forum.pycom.io/topic/4775.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 01 May 2019 20:02:13 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [solved] MQTT and tls on Fri, 10 May 2019 21:14:01 GMT]]></title><description><![CDATA[<p dir="auto">Hello there,</p>
<p dir="auto">I have to use mqtt over tls connection.<br />
right now I am using <a href="https://github.com/micropython/micropython-lib/tree/master/umqtt.simple" target="_blank" rel="noopener noreferrer nofollow">simple mqtt lib</a><br />
Can you recommend me a library, or some code snippet? So far googleing doesn't brought me any luck</p>
]]></description><link>https://forum.pycom.io/post/27622</link><guid isPermaLink="true">https://forum.pycom.io/post/27622</guid><dc:creator><![CDATA[tttadam]]></dc:creator><pubDate>Fri, 10 May 2019 21:14:01 GMT</pubDate></item><item><title><![CDATA[Reply to [solved] MQTT and tls on Thu, 02 May 2019 05:39:56 GMT]]></title><description><![CDATA[<p dir="auto">The builtin AWS IoT library uses MQTT via SSL.<br />
<a href="https://github.com/pycom/pycom-micropython-sigfox/tree/master/esp32/frozen/Common" target="_blank" rel="noopener noreferrer nofollow">https://github.com/pycom/pycom-micropython-sigfox/tree/master/esp32/frozen/Common</a></p>
]]></description><link>https://forum.pycom.io/post/27628</link><guid isPermaLink="true">https://forum.pycom.io/post/27628</guid><dc:creator><![CDATA[Martinnn]]></dc:creator><pubDate>Thu, 02 May 2019 05:39:56 GMT</pubDate></item><item><title><![CDATA[Reply to [solved] MQTT and tls on Fri, 03 May 2019 05:26:32 GMT]]></title><description><![CDATA[<p dir="auto">hmmm, Can you show me an example how the TLS part works, how should I use it?<br />
Thanks.</p>
]]></description><link>https://forum.pycom.io/post/27664</link><guid isPermaLink="true">https://forum.pycom.io/post/27664</guid><dc:creator><![CDATA[tttadam]]></dc:creator><pubDate>Fri, 03 May 2019 05:26:32 GMT</pubDate></item><item><title><![CDATA[Reply to [solved] MQTT and tls on Fri, 03 May 2019 19:45:22 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.pycom.io/uid/3340">@tttadam</a><br />
using the default mqtt library and the ussl library<br />
put the root ca certificate in the cert directory (you have to rename it ca.pem in earlier versions but than maybe changed)<br />
the communications now go over ssl. use the mqttc client as before.</p>
<pre><code>from mqtt import MQTTClient
import ussl

# mqtt definitions
ssl_params = {'cert_reqs':ussl.CERT_REQUIRED, 'ca_certs':'/flash/cert/ca.pem'}
mqttc = MQTTClient(
    &lt;yourmachinename&gt;,
    &lt;yourmqttserver&gt;,
    keepalive=60,
    ssl=True,
    ssl_params=ssl_params
)
</code></pre>
<p dir="auto">best regards<br />
André</p>
]]></description><link>https://forum.pycom.io/post/27691</link><guid isPermaLink="true">https://forum.pycom.io/post/27691</guid><dc:creator><![CDATA[andrethemac]]></dc:creator><pubDate>Fri, 03 May 2019 19:45:22 GMT</pubDate></item><item><title><![CDATA[Reply to [solved] MQTT and tls on Sun, 05 May 2019 21:34:46 GMT]]></title><description><![CDATA[<p dir="auto">Thanks for the library, and sample. That was a great help.<br />
Let me share my result so far.</p>
<p dir="auto">So my first error was: cannot convert str to int. for this line</p>
<pre><code>self.sock = ussl.wrap_socket(self.sock, **self.ssl_params)
</code></pre>
<p dir="auto">in <a href="http://simple.py" target="_blank" rel="noopener noreferrer nofollow">simple.py</a>, This is my call by the way:</p>
<pre><code>c = MQTTClient(client_id=&quot;GH001a&quot;, server=&quot;######&quot;,user=b&quot;######&quot;, password=b&quot;#####&quot;, ssl=True, ssl_params={&quot;cert_reqs&quot;:&quot;ssl.CERT_REQUIRED&quot;, &quot;ca_certs&quot;:&quot;/flash/cert/fullchain1.pem&quot;})
</code></pre>
<p dir="auto">what I come up with (I know it's not nice) to hard code into the <a href="http://simple.py" target="_blank" rel="noopener noreferrer nofollow">simple.py</a> file like this:</p>
<pre><code> self.sock = ssl.wrap_socket(self.sock, cert_reqs=ssl.CERT_REQUIRED, ca_certs='/flash/cert/fullchain1.pem')
</code></pre>
<p dir="auto">The second error wast that CA file not found. That was not hard to crack, just edit pymark.json sync_file_types attribute.</p>
<p dir="auto">The third and current error is MQTTException: 5 for line 102 in <a href="http://simple.py" target="_blank" rel="noopener noreferrer nofollow">simple.py</a></p>
<pre><code>raise MQTTException(resp[3])
</code></pre>
<p dir="auto">on the server side it's look like this: Socket error on client &lt;unknown&gt;, disconnecting.</p>
<p dir="auto">this is where I'am stuck right now.</p>
]]></description><link>https://forum.pycom.io/post/27724</link><guid isPermaLink="true">https://forum.pycom.io/post/27724</guid><dc:creator><![CDATA[tttadam]]></dc:creator><pubDate>Sun, 05 May 2019 21:34:46 GMT</pubDate></item><item><title><![CDATA[Reply to [solved] MQTT and tls on Fri, 10 May 2019 21:13:40 GMT]]></title><description><![CDATA[<p dir="auto">I found the issue.<br />
I got wrong login name and pass from the client....</p>
]]></description><link>https://forum.pycom.io/post/27819</link><guid isPermaLink="true">https://forum.pycom.io/post/27819</guid><dc:creator><![CDATA[tttadam]]></dc:creator><pubDate>Fri, 10 May 2019 21:13:40 GMT</pubDate></item><item><title><![CDATA[Reply to [solved] MQTT and tls on Thu, 14 Jan 2021 01:26:31 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.pycom.io/uid/1962">@andrethemac</a> Hi, how do I add the certificate to the device flash.?</p>
]]></description><link>https://forum.pycom.io/post/36494</link><guid isPermaLink="true">https://forum.pycom.io/post/36494</guid><dc:creator><![CDATA[JOSE RODRIGUEZ]]></dc:creator><pubDate>Thu, 14 Jan 2021 01:26:31 GMT</pubDate></item><item><title><![CDATA[Reply to [solved] MQTT and tls on Fri, 15 Jan 2021 11:29:52 GMT]]></title><description><![CDATA[<p dir="auto">You can upload it either through FTP, or put it in the project folder and add the extension to 'upload file types' in the Pymakr Global settings (I think its already in there)</p>
<p dir="auto">Gijs</p>
]]></description><link>https://forum.pycom.io/post/36548</link><guid isPermaLink="true">https://forum.pycom.io/post/36548</guid><dc:creator><![CDATA[Gijs]]></dc:creator><pubDate>Fri, 15 Jan 2021 11:29:52 GMT</pubDate></item><item><title><![CDATA[Reply to [solved] MQTT and tls on Fri, 29 Oct 2021 14:19:57 GMT]]></title><description><![CDATA[<p dir="auto">Just want to share actual working sample.</p>
<p dir="auto">NOTE: Checking server certificate is DISABLED in this case.<br />
You need <code>CERT_REQUIRED</code> or <code>CERT_REQUIRED</code> judging from documentation.</p>
<p dir="auto">But, by some reason in my build <code>ussl.CERT_REQUIRED</code> gave &quot;...object has no attribute...&quot;.</p>
<pre><code class="language-python"># ---------------------------------------------
# Tested setup: 
#      - Traefik Proxy 2.5 (Let's Encrypt Cert)
#      - Mosquitto 2.0.16
#      - MicroPython 1.17
# ----------------------------------------------
from umqtt.simple import MQTTClient

HOST = &quot;&lt;HOST&gt;&quot;

# Without server_hostname it wan't connect (by some reason)
ssl_params = {&quot;server_hostname&quot;: HOST}  

c = MQTTClient(&quot;&lt;client_id&gt;&quot;,
               server=HOST,
               port=8883,
               user=&quot;&lt;username&gt;&quot;,
               password=&quot;&lt;password&gt;&quot;,
               # Need keepalive &gt; 0 or got MqttException(2)
               keepalive=10,          
               ssl=True,
               ssl_params=ssl_params)
</code></pre>
]]></description><link>https://forum.pycom.io/post/39474</link><guid isPermaLink="true">https://forum.pycom.io/post/39474</guid><dc:creator><![CDATA[Mr Keuz]]></dc:creator><pubDate>Fri, 29 Oct 2021 14:19:57 GMT</pubDate></item></channel></rss>