<?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>CoAP with DTLS 1.2 on download sample</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/89213/coap-with-dtls-1-2-on-download-sample</link><description>hi, 
 I use download sample on nRF9160DK. I try to use CoAP with DTLS, but the SAMPLE_FILE_URL only support http and https url, I can&amp;#39;t find another coaps server to replace it. How can I use CoAP with DTLS on download sample?</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 16 Nov 2022 06:54:05 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/89213/coap-with-dtls-1-2-on-download-sample" /><item><title>RE: CoAP with DTLS 1.2 on download sample</title><link>https://devzone.nordicsemi.com/thread/395900?ContentTypeID=1</link><pubDate>Wed, 16 Nov 2022 06:54:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9a338991-3aac-4a2d-a440-7279023aed49</guid><dc:creator>Harvey Zheng</dc:creator><description>&lt;p&gt;Thaks,&amp;nbsp;I achieved&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CoAP with DTLS 1.2 on download sample</title><link>https://devzone.nordicsemi.com/thread/381409?ContentTypeID=1</link><pubDate>Fri, 12 Aug 2022 15:22:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9ea080e3-9a89-48fd-8e2c-61d4c1b6bb46</guid><dc:creator>Didrik Rokhaug</dc:creator><description>&lt;p&gt;Hi, and sorry for the slow response.&lt;/p&gt;
&lt;p&gt;Jonathan has left on vacation, so I have taken over your ticket.&lt;/p&gt;
&lt;p&gt;Here is a version of the coap_client project that is modified to use DTLS: &lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/5327.coap_5F00_client.zip"&gt;devzone.nordicsemi.com/.../5327.coap_5F00_client.zip&lt;/a&gt; (my changes aren&amp;#39;t the cleanest, but it should be good enough to show what must be done)&lt;/p&gt;
&lt;p&gt;One important thing to note is that the PSK must be converted to ASCII hex (I used the &amp;quot;Client_identity&amp;quot;/&amp;quot;secretPSK&amp;quot; pair).&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: CoAP with DTLS 1.2 on download sample</title><link>https://devzone.nordicsemi.com/thread/377576?ContentTypeID=1</link><pubDate>Tue, 19 Jul 2022 10:13:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7d43b279-ee37-49a8-9803-f6822c7631a3</guid><dc:creator>Harvey Zheng</dc:creator><description>&lt;p class="md-end-block md-p md-focus"&gt;&lt;span class="md-plain"&gt;Hi，&lt;/span&gt;&lt;/p&gt;
&lt;p class="md-end-block md-p"&gt;&lt;span class="md-plain"&gt;Now I modify the code and try to connect to the server `coap://californium.eclipseprojects.io`&lt;/span&gt;&lt;/p&gt;
&lt;p class="md-end-block md-p"&gt;&lt;span class="md-plain"&gt;Firstly, I download &lt;/span&gt;&lt;span class="md-meta-i-c md-link"&gt;&lt;a href="https://github.com/boaks/zephyr-coaps-client/tree/main/src"&gt;&lt;span class="md-plain"&gt;zephyr-coaps-client&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;span class="md-plain"&gt;&amp;nbsp;to my nRF9160 DK, and it can connect to the server properly&lt;/span&gt;&lt;/p&gt;
&lt;p class="md-end-block md-p"&gt;&lt;span class="md-plain"&gt;Then, I use my program which base on &lt;/span&gt;&lt;span class="md-meta-i-c md-link"&gt;&lt;a href="https://github.com/nrfconnect/sdk-nrf/tree/v2.0.0/samples/nrf9160/coap_client"&gt;&lt;span class="md-plain"&gt;NCS2.0 nrf/sample/nrf9160/coap-client&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="md-end-block md-p"&gt;&lt;span class="md-plain"&gt;Here is the PSK and PSK Identity I used.&lt;/span&gt;&lt;/p&gt;
&lt;p class="md-end-block md-p"&gt;&lt;span class="md-plain"&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static unsigned char psk_id[] = &amp;quot;cali.351516172719221&amp;quot;; 
static size_t psk_id_length = sizeof(psk_id) - 1; 
static unsigned char psk_key[] = &amp;quot;.fornium&amp;quot;; 
static size_t psk_key_length = sizeof(psk_key) - 1;

/* Provision certificate to modem */
static int cert_provision(void)
{
	int err;

    err = modem_key_mgmt_write(SEC_TAG,
				   MODEM_KEY_MGMT_CRED_TYPE_IDENTITY,
				   psk_id, psk_id_length);
	if (err) {
		printk(&amp;quot;Failed to provision certificate, err %d\n&amp;quot;, err);
		return err;
	}

    printk(&amp;quot;Provisioning PSK\n&amp;quot;);
	/*  Provision PSK to the modem */
	err = modem_key_mgmt_write(SEC_TAG,
				   MODEM_KEY_MGMT_CRED_TYPE_PSK,
				   psk_key, psk_key_length);
	if (err) {
		printk(&amp;quot;Failed to provision certificate, err %d\n&amp;quot;, err);
		return err;
	}

	return 0;
}&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="md-end-block md-p"&gt;&lt;span class="md-plain"&gt;And I set my `encryption suite`&lt;/span&gt;&lt;span class="md-plain"&gt;&amp;nbsp;as follow. That doesn&amp;#39;t seem like a problem, right.&lt;/span&gt;&lt;/p&gt;
&lt;p class="md-end-block md-p"&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define TLS_NULL_WITH_NULL_NULL 0x0000 /&amp;lt; NULL cipher */ 
#define TLS_PSK_WITH_AES_128_CCM 0xC0A4 /&amp;lt; see RFC 6655 */ 
#define TLS_PSK_WITH_AES_128_CCM_8 0xC0A8 /**&amp;lt; see RFC 6655 */

nrf_sec_cipher_t cipher_list[] = { 
TLS_PSK_WITH_AES_128_CCM, 
TLS_PSK_WITH_AES_128_CCM_8, 
TLS_NULL_WITH_NULL_NULL, };

err = setsockopt(fd, SOL_TLS, TLS_CIPHERSUITE_LIST, cipher_list, sizeof(cipher_list)); 
if (err) { /* Failed to set up cipher suite list. */ return -errno; } &lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="md-end-block md-p"&gt;&lt;span class="md-plain"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p class="md-end-block md-p"&gt;&lt;span class="md-plain"&gt;Now I use this PSK、PSK Identity and encryption suite to connect the server `californium.eclipseprojects.io`&lt;/span&gt;&lt;span class="md-plain"&gt;. But when the client sends `client key exchange`&lt;/span&gt;&lt;span class="md-plain"&gt;, the server does not respond.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1658234037289v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;My Wireshark log as follow:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/trace_2D00_2022_2D00_07_2D00_19T12_2D00_27_2D00_14.230Z.zip"&gt;devzone.nordicsemi.com/.../trace_2D00_2022_2D00_07_2D00_19T12_2D00_27_2D00_14.230Z.zip&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CoAP with DTLS 1.2 on download sample</title><link>https://devzone.nordicsemi.com/thread/377057?ContentTypeID=1</link><pubDate>Fri, 15 Jul 2022 01:13:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:23de15ff-d0b2-411d-91a0-9e1b1f5df4e4</guid><dc:creator>Harvey Zheng</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I use NCS 2.0 and 9160modem V1.3.2. Imodified it according to your idea, but still fail. In the code I need to add the following code, I don&amp;#39;t known what else I need to add.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;nrf_sec_cipher_t cipher_list[] = { 0xC0A8 };
err = setsockopt(dl-&amp;gt;fd, SOL_TLS, TLS_CIPHERSUITE_LIST, cipher_list, sizeof(cipher_list));
if (err) {
    /* Failed to set up cipher suite list. */
    goto cleanup;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static int cert_provision(void)
{
	int err;
	bool exists;

    /*----------- PSK -----------------*/
    err = modem_key_mgmt_exists(SEC_TAG,
				    MODEM_KEY_MGMT_CRED_TYPE_PSK,
				    &amp;amp;exists);
	if (err) {
		printk(&amp;quot;Failed to check for certificates err %d\n&amp;quot;, err);
		return err;
	}

	if (exists) {
		printk(&amp;quot;PSK &amp;quot;);
		/* Let&amp;#39;s compare the existing credential */
		err = modem_key_mgmt_cmp(SEC_TAG,
					 MODEM_KEY_MGMT_CRED_TYPE_PSK,
					 key, sizeof(key));
		printk(&amp;quot;%s\n&amp;quot;, err ? &amp;quot;mismatch&amp;quot; : &amp;quot;match&amp;quot;);
		if (!err) {
			return 0;
		}
	} else {
        printk(&amp;quot;PSK is nonexistent\n&amp;quot;);
    }

    printk(&amp;quot;Provisioning PSK\n&amp;quot;);
	err = modem_key_mgmt_write(SEC_TAG,
				   MODEM_KEY_MGMT_CRED_TYPE_PSK,
				   key, sizeof(key));
	if (err) {
		printk(&amp;quot;Failed to provision certificate, err %d\n&amp;quot;, err);
		return err;
	}

	return 0;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;My trace log as follow:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/trace_2D00_2022_2D00_07_2D00_14T10_2D00_04_2D00_46.760Z.zip"&gt;devzone.nordicsemi.com/.../trace_2D00_2022_2D00_07_2D00_14T10_2D00_04_2D00_46.760Z.zip&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CoAP with DTLS 1.2 on download sample</title><link>https://devzone.nordicsemi.com/thread/376426?ContentTypeID=1</link><pubDate>Mon, 11 Jul 2022 12:26:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5db7019d-6c9b-431f-bcba-7e99b2bf0b5d</guid><dc:creator>JONATHAN LL</dc:creator><description>&lt;p&gt;Hello,&lt;br /&gt;You need to&amp;nbsp;set SAMPLE_FILE_CUSTOM to specify a custom server, and enable CONFIG_COAP for COAP to work,&amp;nbsp;&lt;span&gt;And change the cert_provision function to write a PSK rather than a CA chain.&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;So set up a CoAPs server, set CONFIG_SAMPLE_FILE_URL to point to your CoAPs server.&lt;br /&gt;SAMPLE_FILE_URL supports all possible types of servers (it is just a string), but we only have defaults for HTTP and HTTPS. So you need to set up one for yourself.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Jonathan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CoAP with DTLS 1.2 on download sample</title><link>https://devzone.nordicsemi.com/thread/376251?ContentTypeID=1</link><pubDate>Fri, 08 Jul 2022 14:12:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2119ac05-d5e4-4073-add1-56e06894644d</guid><dc:creator>JONATHAN LL</dc:creator><description>[quote user="Magdalena"]Could you tell me when the holiday ends?&amp;nbsp;I applied it to the project,&amp;nbsp;I hope to hear from you as soon as possible.[/quote]
&lt;p&gt;Week 31 we will back in full force, so expect a quicker response time from then on. But we are still working to solve the tickets here on Devzone but there is fewer staff so things will take some more time then usual.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;What version of the nRF Connect SDK are you using?&lt;br /&gt;&lt;br /&gt;Regards,&lt;br /&gt;Jonathan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CoAP with DTLS 1.2 on download sample</title><link>https://devzone.nordicsemi.com/thread/375834?ContentTypeID=1</link><pubDate>Wed, 06 Jul 2022 13:55:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a112c63b-4e0f-4dfb-aa8a-d076d83a62dd</guid><dc:creator>Harvey Zheng</dc:creator><description>&lt;p&gt;hi&lt;/p&gt;
&lt;p&gt;Could you tell me when the holiday ends?&amp;nbsp;I applied it to the project,&amp;nbsp;I hope to hear from you as soon as possible.&lt;/p&gt;
&lt;p&gt;thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CoAP with DTLS 1.2 on download sample</title><link>https://devzone.nordicsemi.com/thread/375807?ContentTypeID=1</link><pubDate>Wed, 06 Jul 2022 13:01:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d0d6c845-c437-45a0-a16a-f55dfb3742c7</guid><dc:creator>JONATHAN LL</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;&lt;br /&gt;Due to the holiday season in Norway&amp;nbsp;response time&amp;nbsp;is slower than usual. Pardon the&amp;nbsp;inconvenience.&lt;br /&gt;&lt;br /&gt;We will respond when we have time to look at you case.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Regards,&lt;br /&gt;Jonathan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>