<?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 handshake in aws_iot_connect()  function</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/66909/tls-handshake-in-aws_iot_connect-function</link><description>Hi, 
 
 Currently we working on a project that uses: 
 
 nRF9160 
 Zyphre OS 
 Segger Embedded Studio for Arm (Nordic Edition) V4.52 
 SDK v1.3 
 
 
 CONFIG_MQTT_LIB_TLS 
 
 
 
 
 In nRF Connect SDK - AWS IoT it mentions that the TLS handshake is performed</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 26 Oct 2020 13:02:25 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/66909/tls-handshake-in-aws_iot_connect-function" /><item><title>RE: TLS handshake in aws_iot_connect()  function</title><link>https://devzone.nordicsemi.com/thread/276864?ContentTypeID=1</link><pubDate>Mon, 26 Oct 2020 13:02:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:28a49417-c853-44e7-b051-f86a3723a531</guid><dc:creator>Didrik Rokhaug</dc:creator><description>&lt;p&gt;A TLS handshake will be done if you call &lt;code&gt;connect()&lt;/code&gt; on&amp;nbsp; a TLS socket.&lt;/p&gt;
&lt;p&gt;A TLS socket is created by calling &lt;code&gt;socket(sa_family, SOCK_STREAM, IPPROTO_TLS_1_2)&lt;/code&gt;, where &lt;code&gt;sa_family&lt;/code&gt; is the IP version (&lt;code&gt;AF_INET&lt;/code&gt; for IPv4 or &lt;code&gt;AF_INET6&lt;/code&gt; for IPv6)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TLS handshake in aws_iot_connect()  function</title><link>https://devzone.nordicsemi.com/thread/276754?ContentTypeID=1</link><pubDate>Sun, 25 Oct 2020 19:25:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1f44852a-54c9-499b-bd55-70d3d45c5f2b</guid><dc:creator>ReneDelgado</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;We are porting &lt;span lang="en"&gt; &lt;a href="https://github.com/aws/aws-iot-device-sdk-embedded-C"&gt;aws-iot-device-sdk-embedded-C&lt;/a&gt;, and TLS handshake is requirement of the connect function parameter, &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;We want to know which function we need to call from Cortex M33 to trigger that the modem do the TLS handshake.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Ren&amp;eacute; D.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TLS handshake in aws_iot_connect()  function</title><link>https://devzone.nordicsemi.com/thread/275503?ContentTypeID=1</link><pubDate>Mon, 19 Oct 2020 07:55:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ccbc4ee6-7028-4a28-a109-f3aa3d18d257</guid><dc:creator>Didrik Rokhaug</dc:creator><description>&lt;p&gt;The TLS stack is in the modem, so the modem will handle the TLS handshake.&lt;/p&gt;
&lt;p&gt;Why do you want to know where the TLS handshake happens?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TLS handshake in aws_iot_connect()  function</title><link>https://devzone.nordicsemi.com/thread/275453?ContentTypeID=1</link><pubDate>Sat, 17 Oct 2020 16:18:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:732b43c6-b55a-4338-a5cc-7abecc5270d9</guid><dc:creator>ReneDelgado</dc:creator><description>&lt;p&gt;Hello, thanks for your answer, it describes very well the calls to the functions. But It not mentioning anything related to TLS Handshake therefore I am not answering my question.&lt;br /&gt;&lt;br /&gt;What we want to know is:&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#800000;"&gt;Where is the TLS Hanshake done, mentioned in the note that I pasted in my previous comment?&lt;/span&gt; The notes are in the Nordic Wiki for that reason I question to your Team.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best Regards,&lt;/p&gt;
&lt;p&gt;Ren&amp;eacute; D.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TLS handshake in aws_iot_connect()  function</title><link>https://devzone.nordicsemi.com/thread/274351?ContentTypeID=1</link><pubDate>Mon, 12 Oct 2020 13:34:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:30ac283f-109b-4496-abc0-f3c0757c7067</guid><dc:creator>Didrik Rokhaug</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&lt;code&gt;aws_iot_connect()&lt;/code&gt; calls &lt;code&gt;mqtt_connect()&lt;/code&gt; which calls &lt;code&gt;client_connect()&lt;/code&gt; which calls &lt;code&gt;mqtt_transport_connect()&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;mqtt_transport_connect()&lt;/code&gt; calls &lt;code&gt;transport_fn[client-&amp;gt;transport.type].connect()&lt;/code&gt;. The MQTT library supports three transport layers, TCP, TLS and websockets. Each of the transports has defined a struct, filled with transport specific functions, and placed those structs in the transport_fn array. This way, the MQTT library can use a single interface for both transports.&lt;/p&gt;
&lt;p&gt;As you are using TLS, &lt;code&gt;mqtt_transport_connect()&lt;/code&gt; will call &lt;code&gt;mqtt_client_tls_connect()&lt;/code&gt; in mqtt_transport_socket_tls.c. In &lt;code&gt;mqtt_client_tls_connect()&lt;/code&gt;, you will see the socket be created, and the relevant socket options being set. In the end, &lt;code&gt;mqtt_client_tls_connect()&lt;/code&gt; calls &lt;code&gt;connect()&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The call to connect() will go through Zephyr&amp;#39;s socket offloading layer (you are free to explore the details of this yourself), and end up &lt;code&gt;nrf91_socket_offload_connect()&lt;/code&gt; in nrf/lib/bsdlib/nrf91_socket.c. Here, we convert from Zephyr&amp;#39;s sockets, to bsdlib&amp;#39;s nrf_sockets. The call to &lt;code&gt;connect()&lt;/code&gt; ends up converted to a call to &lt;code&gt;nrf_connect()&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;nrf_connect()&lt;/code&gt; is implemented in bsdlib, which is only distributed as a pre-compiled library, so our exploration ends here. However, bsdlib will forward the function call to the modem, which is where the TLS stack resides.&lt;/p&gt;
&lt;p&gt;In short, the call to &lt;code&gt;aws_iot_connect()&lt;/code&gt; will go through a lot of intermediate functions, before ending up in the modem, which is where the magic happens.&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>