CoAP with DTLS 1.2 on download sample

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't find another coaps server to replace it. How can I use CoAP with DTLS on download sample?

  • Hi,

    Due to the holiday season in Norway response time is slower than usual. Pardon the inconvenience.

    We will respond when we have time to look at you case. 

    Regards,
    Jonathan

  • hi

    Could you tell me when the holiday ends? I applied it to the project, I hope to hear from you as soon as possible.

    thanks

  • Harvey Zheng said:
    Could you tell me when the holiday ends? I applied it to the project, I hope to hear from you as soon as possible.

    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. 


    What version of the nRF Connect SDK are you using?

    Regards,
    Jonathan

  • Hello,
    You need to set SAMPLE_FILE_CUSTOM to specify a custom server, and enable CONFIG_COAP for COAP to work, And change the cert_provision function to write a PSK rather than a CA chain.

    So set up a CoAPs server, set CONFIG_SAMPLE_FILE_URL to point to your CoAPs server.
    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.

    Regards,
    Jonathan

  • Hi,

    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't known what else I need to add.

    nrf_sec_cipher_t cipher_list[] = { 0xC0A8 };
    err = setsockopt(dl->fd, SOL_TLS, TLS_CIPHERSUITE_LIST, cipher_list, sizeof(cipher_list));
    if (err) {
        /* Failed to set up cipher suite list. */
        goto cleanup;
    }

    static int cert_provision(void)
    {
    	int err;
    	bool exists;
    
        /*----------- PSK -----------------*/
        err = modem_key_mgmt_exists(SEC_TAG,
    				    MODEM_KEY_MGMT_CRED_TYPE_PSK,
    				    &exists);
    	if (err) {
    		printk("Failed to check for certificates err %d\n", err);
    		return err;
    	}
    
    	if (exists) {
    		printk("PSK ");
    		/* Let's compare the existing credential */
    		err = modem_key_mgmt_cmp(SEC_TAG,
    					 MODEM_KEY_MGMT_CRED_TYPE_PSK,
    					 key, sizeof(key));
    		printk("%s\n", err ? "mismatch" : "match");
    		if (!err) {
    			return 0;
    		}
    	} else {
            printk("PSK is nonexistent\n");
        }
    
        printk("Provisioning PSK\n");
    	err = modem_key_mgmt_write(SEC_TAG,
    				   MODEM_KEY_MGMT_CRED_TYPE_PSK,
    				   key, sizeof(key));
    	if (err) {
    		printk("Failed to provision certificate, err %d\n", err);
    		return err;
    	}
    
    	return 0;
    }

    My trace log as follow:

    trace-2022-07-14T10-04-46.760Z.zip

Related