<?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>nRF9160 LwM2M sample app: cannot update DTLS keys dynamically</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/56295/nrf9160-lwm2m-sample-app-cannot-update-dtls-keys-dynamically</link><description>Hi, 
 I have extended the nRF9160 sample app to use Leshan bootstrap server. Using a boostrap server means getting DTLS PSK crypto keys from the bootstrap server. Hence the device must be able to update the keys while connecting. However, it seems this</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 29 Jan 2020 15:29:19 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/56295/nrf9160-lwm2m-sample-app-cannot-update-dtls-keys-dynamically" /><item><title>RE: nRF9160 LwM2M sample app: cannot update DTLS keys dynamically</title><link>https://devzone.nordicsemi.com/thread/231722?ContentTypeID=1</link><pubDate>Wed, 29 Jan 2020 15:29:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5fe09987-d278-435e-9144-c3d3097251f9</guid><dc:creator>Didrik Rokhaug</dc:creator><description>&lt;p&gt;Let me know what you find out. It is valuable feedback to our developers.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 LwM2M sample app: cannot update DTLS keys dynamically</title><link>https://devzone.nordicsemi.com/thread/231704?ContentTypeID=1</link><pubDate>Wed, 29 Jan 2020 14:52:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:29395f7a-ef1d-405a-9085-963ac1c4ce50</guid><dc:creator>Bjorn191023</dc:creator><description>&lt;p&gt;Thanks a lot Didrik,&lt;/p&gt;
&lt;p&gt;I will review the proposed solution again, I might have misunderstood the dynamics of the LwM2M client. I get back to you.&lt;/p&gt;
&lt;p&gt;BR / Bj&amp;ouml;rn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 LwM2M sample app: cannot update DTLS keys dynamically</title><link>https://devzone.nordicsemi.com/thread/231650?ContentTypeID=1</link><pubDate>Wed, 29 Jan 2020 12:50:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fb9417a0-aded-4799-9a6e-ed4cf70bc4f8</guid><dc:creator>Didrik Rokhaug</dc:creator><description>&lt;p&gt;Hi, and sorry for the wait.&lt;/p&gt;
&lt;p&gt;Here is the reply I got from the NCS team:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;I don&amp;#39;t agree with the customer argumentation regarding `load_credentials`. When this function is called by the LWM2M engine, the socket that the bootstrap procedure was run on is already closed, so there is no active DTLS session.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;From what I&amp;#39;ve seen in the LWM2M implementation, the LWM2M engine will store the DTLS credentials received in the object instance stored in RAM (during the bootstrap procedure). As already pointed out, we should not try to store the credentials in the modem at this point (we can register `post_write_cb` callback), as it will break the bootstrapping procedure. I see two ways how we could tackle this problem:&lt;/em&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;em&gt;When the bootstrap server finishes the bootstrap procedure, we get `LWM2M_RD_CLIENT_EVENT_BOOTSTRAP_TRANSFER_COMPLETE` event in the application. At this point, the connection with the bootstrap server is done, and we have not started the connection with the actual LWM2M server. It should be safe to put the link down at this point, read the credentials from the security object and store them in the modem,&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Implement and register a custom `load_credentials` function as suggested, which is called just before a new socket is created. It will be called after the bootstrap procedure, and before the actual LWM2M server registration. It could be used to store the credentials in the modem as well.&lt;/em&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;em&gt;Of course, I cannot guarantee that there is no not-yet-discovered bug in the LWM2M implementation as unfortunately, even the upstream sample does not show how to combine DTLS + bootstrapping.&lt;/em&gt;&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><item><title>RE: nRF9160 LwM2M sample app: cannot update DTLS keys dynamically</title><link>https://devzone.nordicsemi.com/thread/230797?ContentTypeID=1</link><pubDate>Fri, 24 Jan 2020 09:01:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9910ef9c-7f4e-4a23-8376-97930068d76c</guid><dc:creator>Didrik Rokhaug</dc:creator><description>&lt;p&gt;Hi.&lt;/p&gt;
&lt;p&gt;I have asked the NCS team if they know of any way around the LwM2M client&amp;#39;s limitations.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ll come back to you when I get a reply.&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><item><title>RE: nRF9160 LwM2M sample app: cannot update DTLS keys dynamically</title><link>https://devzone.nordicsemi.com/thread/230516?ContentTypeID=1</link><pubDate>Thu, 23 Jan 2020 09:20:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0b323058-8883-4e75-9c5d-06c297dcb3d5</guid><dc:creator>Bjorn191023</dc:creator><description>&lt;p&gt;Hi Didrik,&lt;/p&gt;
[quote userid="81181" url="~/f/nordic-q-a/56295/nrf9160-lwm2m-sample-app-cannot-update-dtls-keys-dynamically/230422"]&amp;nbsp;I have not used the LwM2M client a lot, but can you not write a function that disconnects, write the PSK and connect, then provide a pointer to that function in the load_credentials field in the lwm2m_ctx struct?[/quote]
&lt;p&gt;To my understanding it is not possible. If I disconnect on low level then the DTLS session will be invalidated, meaning that we need to reconnect to &amp;quot;coaps://&amp;lt;url&amp;gt;:&amp;lt;port&amp;gt;&amp;quot;. The only way to that with the LwM2M client is to &amp;quot;restart&amp;quot;. Doing what you propose would require a change of the LwM2M client API&amp;nbsp;.&lt;/p&gt;
[quote userid="81181" url="~/f/nordic-q-a/56295/nrf9160-lwm2m-sample-app-cannot-update-dtls-keys-dynamically/230422"]This is because of timing restrictions in the modem. As a certificate can be quite large, it is not guaranteed that the modem is able to write it to flash (which takes time) while simultaneously upholding the timing demands of the cellular network.[/quote]
&lt;p&gt;Ok, I know that problem :-) so the reason is understood. However, I have a proposal. The bootstrap server use cases gives a session key by design. A session key is volatile while the modem only stores non-volatile keys. I propose to add the possibility to store volatile keys in the modem. This would support the LwM2M boostrap server use case out of the box.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;BR / Bj&amp;ouml;rn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 LwM2M sample app: cannot update DTLS keys dynamically</title><link>https://devzone.nordicsemi.com/thread/230422?ContentTypeID=1</link><pubDate>Wed, 22 Jan 2020 16:33:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3ede84f1-edaf-4be4-9d52-230b4391941c</guid><dc:creator>Didrik Rokhaug</dc:creator><description>[quote user="Bjorn191023"]Regarding your implementation advice: it is not possible to disconnect, store key and connect again due to the way the LwM2M client is working in your platform. When I reconnect the&amp;nbsp;&lt;span&gt;LwM2M client&amp;nbsp;will always go to the bootstrap server meaning I can get a new key...so I am stuck in an infinite loop.&lt;/span&gt;[/quote]
&lt;p&gt;&amp;nbsp;I have not used the LwM2M client a lot, but can you not write a function that disconnects, write the PSK and connect, then provide a pointer to that function in the load_credentials field in the lwm2m_ctx struct?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;[quote user="Bjorn191023"][/quote]&lt;/p&gt;
&lt;p&gt;&lt;span&gt;1) Why is it not possible to change keys when connected? Security?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;2) Do you have any plans to open for key change when connected?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;This is because of timing restrictions in the modem. As a certificate can be quite large, it is not guaranteed that the modem is able to write it to flash (which takes time) while simultaneously upholding the timing demands of the cellular network.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 LwM2M sample app: cannot update DTLS keys dynamically</title><link>https://devzone.nordicsemi.com/thread/230282?ContentTypeID=1</link><pubDate>Wed, 22 Jan 2020 09:50:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:be92ff6b-2b29-4283-bb1d-7511e72d561a</guid><dc:creator>Bjorn191023</dc:creator><description>&lt;p&gt;Hi Didrik,&lt;/p&gt;
&lt;p&gt;Thanks for your response. I have been at a biz trip so I have not been able to respond.&lt;/p&gt;
&lt;p&gt;Regarding your implementation advice: it is not possible to disconnect, store key and connect again due to the way the LwM2M client is working in your platform. When I reconnect the&amp;nbsp;&lt;span&gt;LwM2M client&amp;nbsp;will always go to the bootstrap server meaning I can get a new key...so I am stuck in an infinite loop. To fix this I need to patch your&amp;nbsp;LwM2M client&amp;nbsp;which I want to avoid.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Questions:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;1) Why is it not possible to change keys when connected? Security?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;2) Do you have any plans to open for key change when connected?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;BR / Bj&amp;ouml;rn&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 LwM2M sample app: cannot update DTLS keys dynamically</title><link>https://devzone.nordicsemi.com/thread/228302?ContentTypeID=1</link><pubDate>Thu, 09 Jan 2020 09:31:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d2bd8b9a-fa78-492e-ad18-3630a5e3ded5</guid><dc:creator>Didrik Rokhaug</dc:creator><description>&lt;p&gt;Hi.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""]The IP stack is offloaded in the sample app (CONFIG_NET_SOCKETS_OFFLOAD=y), meaning it is deployed on the modem to my understanding!?[/quote]
&lt;p&gt;&amp;nbsp;That is correct.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""]How do you envision that the bootstrap server scenario shall be implemented?[/quote]
&lt;p&gt;&amp;nbsp;You would have to disconnect from the network after receiving the keys, store them, and then reconnect to the network.&lt;/p&gt;
&lt;p&gt;That is the only way I can think&amp;nbsp; of at the moment.&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>