This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Adding keys to modem

Hi,

nrf-sdk: 1.3

Firmware: 1.2.1

Using offloaded sockets(secrets at the modem side)

My use-case is this: Provision PSK and identity to device at the factory for DTLS use. Use these keys to connect to the cloud(LWM2M bootstrap server) and receive the actual PSK that is used to connect to the LWM2M server in a bootstrap process.

I am having problems when trying to use modem_key_mgmt_write to write the PSK to the modem. After bootstrap is completed with the server, I put the modem to power_off state(also tried the Flight mode). Then I use modem_key_mgmt_delete and modem_key_mgmt_write to write the PSK to the modem. API never returns any errors and everything seems fine. But when modem is back online and I try to use these credentials to connect to the server it does not work. I mainly get -116 and -22 errors. As in not -95, which usually comes if you have invalid credentials.

I've tried to debug this and noticed that at least modem_key_mgmt_cmp never works. If  I call modem_key_mgmt_writemodem_key_mgmt_exists and modem_key_mgmt_cmp in a row, I get the result that key was written succesfully, it exists and does not match.

<dbg> modem_key_mgmt.modem_key_mgmt_cmp: Credential length 0 bytes (expected 18)

At the moment I have another app which I use to flash the PSK at the factory. That app uses exactly the same functions to provision the original factory PSK and that works just fine. By saying that it works, I mean that PSK can be used to connect to the server. Comparing it also always returns 0 length data.

Any hints?

Parents Reply Children
Related