<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>TLS ERROR MQTT - Error in mqtt_connect: -111</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/111177/tls-error-mqtt---error-in-mqtt_connect--111</link><description>Hello, 
 
 I am trying to connect to the MQTT broker that uses a TLS certificate and user/password. I have set the user and password fields of these structs. 
 
 struct mqtt_utf8 pass, user_name; 
 
 
 
 Regarding the server certificate, I have tried</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 06 Jun 2024 08:39:39 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/111177/tls-error-mqtt---error-in-mqtt_connect--111" /><item><title>RE: TLS ERROR MQTT - Error in mqtt_connect: -111</title><link>https://devzone.nordicsemi.com/thread/487655?ContentTypeID=1</link><pubDate>Thu, 06 Jun 2024 08:39:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fd94cfdb-f92d-453c-afa2-694c21995013</guid><dc:creator>tsotnek</dc:creator><description>&lt;p&gt;This issue was fixed by moving struct mqtt_utf8 pass, user_name; to global space. For more detail you can check Zephyr GitHub Issue:&amp;nbsp;&lt;a href="https://github.com/zephyrproject-rtos/zephyr/issues/73089"&gt;github.com/.../73089&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TLS ERROR MQTT - Error in mqtt_connect: -111</title><link>https://devzone.nordicsemi.com/thread/484732?ContentTypeID=1</link><pubDate>Thu, 16 May 2024 14:19:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b0684394-d237-4e96-b88d-769a266de91c</guid><dc:creator>Didrik Rokhaug</dc:creator><description>&lt;p&gt;What server are you connecting to?&lt;/p&gt;
&lt;p&gt;Some, e.g. AWS IoT Core, require that the client ID in the MQTT Connect request is the same as the CN in the device certificate.&lt;/p&gt;
&lt;p&gt;The first packet of Application Data will be the Connect request, and wrong Client ID/CN is the typical cause when the conenction is terminated after the first packet (at least for AWS).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TLS ERROR MQTT - Error in mqtt_connect: -111</title><link>https://devzone.nordicsemi.com/thread/483532?ContentTypeID=1</link><pubDate>Wed, 15 May 2024 13:48:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a5fa542f-dca6-45e4-b33c-6ed4a2d994dd</guid><dc:creator>tsotnek</dc:creator><description>&lt;p&gt;Hello Didrik,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;After numerous attempts I think I got through that problem of -111 error and CONNREFUSED because of unknown CA. I think the issue was the formatting of the certificate.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Now I have different problem error -128 on mqtt_input&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;[00:44:14.755,249] &amp;lt;inf&amp;gt; Lesson4_Exercise2: RRC mode: Connected
[00:44:16.156,097] &amp;lt;inf&amp;gt; Lesson4_Exercise2: MQTT client disconnected: -128
[00:44:16.156,158] &amp;lt;err&amp;gt; Lesson4_Exercise2: Error in mqtt_input: -128
[00:44:16.156,158] &amp;lt;inf&amp;gt; Lesson4_Exercise2: Disconnecting MQTT client
[00:44:16.156,188] &amp;lt;err&amp;gt; Lesson4_Exercise2: Could not disconnect MQTT client: -128&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;This is the log from Wireshark&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;pre class="ui-code" data-mode="text"&gt;83&amp;#160;ip&amp;#160;ip DNS Standard query response 0x36a2 A &amp;quot;servername&amp;quot; CNAME &amp;quot;servername&amp;quot; A &amp;quot;serverip&amp;quot; NS&amp;#160;&amp;quot;server&amp;quot; NS &amp;quot;server&amp;quot; A &amp;quot;server&amp;quot; A &amp;quot;server&amp;quot; AAAA 2001:700:300::209 AAAA 2001:700:300::208
84 10.82.101.95 &amp;quot;serverip&amp;quot; TCP 56805 → 8883 [SYN] Seq=0 Win=6372 Len=0 MSS=708
85 &amp;quot;serverip&amp;quot; 10.82.101.95 TCP 8883 → 56805 [SYN, ACK] Seq=0 Ack=1 Win=64240 Len=0 MSS=1380
86 10.82.101.95 &amp;quot;serverip&amp;quot; TCP 56805 → 8883 [ACK] Seq=1 Ack=1 Win=6372 Len=0
87 10.82.101.95 &amp;quot;serverip&amp;quot; TLSv1.2 Client Hello (SNI=&amp;quot;servername&amp;quot;)
88 &amp;quot;serverip&amp;quot; 10.82.101.95 TCP 8883 → 56805 [ACK] Seq=1 Ack=143 Win=64098 Len=0
89 &amp;quot;serverip&amp;quot; 10.82.101.95 TLSv1.2 Server Hello
90 &amp;quot;serverip&amp;quot; 10.82.101.95 TCP 8883 → 56805 [PSH, ACK] Seq=709 Ack=143 Win=64098 Len=708 [TCP segment of a reassembled PDU]
91 10.82.101.95 &amp;quot;serverip&amp;quot; TCP 56805 → 8883 [ACK] Seq=143 Ack=1417 Win=5664 Len=0
92 &amp;quot;serverip&amp;quot; 10.82.101.95 TLSv1.2 Certificate
93 &amp;quot;serverip&amp;quot; 10.82.101.95 TLSv1.2 Server Key Exchange, Server Hello Done
94 10.82.101.95 &amp;quot;serverip&amp;quot; TCP 56805 → 8883 [ACK] Seq=143 Ack=2125 Win=6159 Len=0
95 10.82.101.95 &amp;quot;serverip&amp;quot; TLSv1.2 Client Key Exchange
96 &amp;quot;serverip&amp;quot; 10.82.101.95 TCP 8883 → 56805 [ACK] Seq=2226 Ack=185 Win=64056 Len=0
97 10.82.101.95 &amp;quot;serverip&amp;quot; TLSv1.2 Change Cipher Spec, Encrypted Handshake Message
98 &amp;quot;serverip&amp;quot; 10.82.101.95 TCP 8883 → 56805 [ACK] Seq=2226 Ack=236 Win=64056 Len=0
99 &amp;quot;serverip&amp;quot; 10.82.101.95 TLSv1.2 Change Cipher Spec, Encrypted Handshake Message
100 10.82.101.95 &amp;quot;serverip&amp;quot; TLSv1.2 Application Data
101 &amp;quot;serverip&amp;quot; 10.82.101.95 TLSv1.2 Encrypted Alert
102 &amp;quot;serverip&amp;quot; 10.82.101.95 TCP 8883 → 56805 [FIN, ACK] Seq=2308 Ack=298 Win=64056 Len=0
103 10.82.101.95 &amp;quot;serverip&amp;quot; TCP 56805 → 8883 [ACK] Seq=298 Ack=2309 Win=5975 Len=0&lt;/pre&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I am unable to decrypt the TLS using server private key due to this log message&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;session uses Diffie-Hellman key exchange (cipher suite 0xC030 TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) and cannot be decrypted using a RSA private key file&lt;/strong&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TLS ERROR MQTT - Error in mqtt_connect: -111</title><link>https://devzone.nordicsemi.com/thread/483497?ContentTypeID=1</link><pubDate>Wed, 15 May 2024 12:11:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a8e94c10-43ba-4919-8ae8-619fbdc5bea1</guid><dc:creator>tsotnek</dc:creator><description>&lt;p&gt;Hello Didrik,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The modem trace contains some sensitive data, I don&amp;#39;t think it would be wise to post it here. But I looked through it using WireShark and it seems to be failing &lt;strong&gt;95 TLSv1.2 Alert (Level: Fatal, Description: Unknown CA)&amp;nbsp;&lt;/strong&gt;due to unknown CA?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Again I tested with both following the instructions on&amp;nbsp;&lt;span&gt;lesson 4.2, generated certificate.h using python script from server certificate .crt file.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;83 DNS Standard query response 0x10e2 A &amp;quot;server&amp;quot; CNAME&amp;#160;&amp;quot;server&amp;quot; A &amp;quot;ip&amp;quot; NS&amp;#160;&amp;quot;server&amp;quot; NS &amp;quot;server&amp;quot; A &amp;quot;IP&amp;quot; A&amp;#160;&amp;quot;IP&amp;quot; AAAA 2001:700:300::209 AAAA 2001:700:300::208
84 TCP 58740 → 8883 [SYN] Seq=0 Win=6372 Len=0 MSS=708
85 TCP 8883 → 58740 [SYN, ACK] Seq=0 Ack=1 Win=64240 Len=0 MSS=1380
86 TCP 58740 → 8883 [ACK] Seq=1 Ack=1 Win=6372 Len=0
87 TLSv1.2 Client Hello (SNI=&amp;quot;server&amp;quot;)
88 TCP 8883 → 58740 [ACK] Seq=1 Ack=143 Win=64098 Len=0
89 TLSv1.2 Server Hello
90 TCP 8883 → 58740 [PSH, ACK] Seq=709 Ack=143 Win=64098 Len=708 [TCP segment of a reassembled PDU]
91 TCP 58740 → 8883 [ACK] Seq=143 Ack=1417 Win=5664 Len=0
92 TLSv1.2 Certificate
93 TCP 58740 → 8883 [ACK] Seq=143 Ack=2125 Win=6159 Len=0
94 TLSv1.2 Server Key Exchange, Server Hello Done
95 TLSv1.2 Alert (Level: Fatal, Description: Unknown CA)
96 TCP 58740 → 8883 [RST, ACK] Seq=150 Ack=2226 Win=58392 Len=0&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Exact same certificate file works perfectly on Node-red and MQTT Explorer.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I tried to also write a certificate using Certificate Manager in sec tag 24. Same problem.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TLS ERROR MQTT - Error in mqtt_connect: -111</title><link>https://devzone.nordicsemi.com/thread/483467?ContentTypeID=1</link><pubDate>Wed, 15 May 2024 11:05:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0cdd147f-ea80-457f-8f10-03ae2b38f754</guid><dc:creator>Didrik Rokhaug</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Can you take a &lt;a href="https://docs.nordicsemi.com/bundle/nrf-connect-cellularmonitor/page/index.html"&gt;modem trace&lt;/a&gt;, so that we can look at the TLS handshake to see where it fails?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Didrik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>