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,
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?

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:
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: