Skip to content

Commit 3be2a3b

Browse files
pascal-nordicmaxd-nordic
authored andcommitted
Include nrfcredstore and update documentation in different sections
1 parent ff32694 commit 3be2a3b

File tree

2 files changed

+75
-31
lines changed

2 files changed

+75
-31
lines changed

ADVANCED.md

Lines changed: 59 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ These Python scripts are designed to assist users in provisioning devices with t
1414
- [Gather Attestation Tokens](#gather-attestation-tokens)
1515
- [Claim Devices](#claim-devices)
1616
- [Creating FOTA Updates](#creating-fota-updates)
17+
- [nRF Credential Store](#nrf-credential-store)
1718

1819
## Overview of Python Utilities for nRF Cloud Integration
1920

@@ -22,6 +23,7 @@ When using nRF9160, these utilities require [Modem firmware v1.3 or later](https
2223
For additional details, refer to the [nRF Cloud Security documentation](https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/external_comp/nrf_cloud.html#security).
2324

2425
## Create CA Cert
26+
2527
This script creates a self-signed CA certificate and an associated EC keypair. The CA cert and private key can then be used to create device credentials. Generally, this script needs to be called only once and then its output can be used to produce many device credentials. The specific values that you specify for the various options are not important, though it is recommended to use reasonable and accurate values for country code, state or province, locality, organization and its unit. The number of days valid defaults to 10 years. The common name could be your company domain name or something similar.
2628

2729
The output file name format is as follows:
@@ -40,8 +42,7 @@ File created: /some/path/my_ca/0x48a2b0c9862ffe08d709864f576caa0a9ff9bfbf_pub.pe
4042

4143
## Device Credentials Installer
4244

43-
This script automates the process of generating and programming device credentials to a device such as a Thingy:91 X or nRF9151-DK running an nRF Connect SDK application containing the [AT Host library](https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/libraries/modem/at_host.html).
44-
The [AT Client sample](https://github.com/nrfconnect/sdk-nrf/tree/main/samples/cellular/at_client) is the simplest implementation of the AT Host library.
45+
This script automates the process of generating and programming device credentials to a device such as the nRF9160-DK, Thingy:91X or nRF9151-DK running an nRF Connect SDK application containing the [AT Host library](https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/libraries/modem/at_host.html) or [AT Shell](https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/libraries/modem/at_shell.html).
4546

4647
Use the `create_ca_cert` script to generate the required CA certificate and CA key before running this script.
4748

@@ -70,12 +71,13 @@ See: [Configuration options for device ID](https://docs.nordicsemi.com/bundle/nc
7071
device_credentials_installer -d --ca ./ca.pem --ca-key ./ca_prv_key.pem --verify
7172
```
7273

73-
#### nrf-\<IMEI\> device ID (for nRF91 DKs and Thingy91s) with verification enabled
74+
#### nrf-\<IMEI\> device ID with verification enabled
7475
```
7576
device_credentials_installer -d --ca ./ca.pem --ca-key ./ca_prv_key.pem --verify --id-imei --id-str nrf-
7677
```
7778

78-
# nRF Cloud Device Onboarding
79+
## nRF Cloud Device Onboarding
80+
7981
The `nrf_cloud_onboard` script performs device onboarding with nRF Cloud.
8082
Your nRF Cloud REST API key is a required parameter and can be found on your [User Account page](https://nrfcloud.com/#/account).
8183
Also required is a CSV file compatible with the [onboarding endpoint](https://api.nrfcloud.com/v1/#operation/ProvisionDevices). You can use the onboarding CSV file produced by `device_credentials_installer`.
@@ -87,7 +89,8 @@ nrf_cloud_onboard --api-key $API_KEY --csv onboard.csv
8789

8890
If the `--res` parameter is used, the onboarding result information will be saved to the specified file instead of printed to the output.
8991

90-
# Modem Credentials Parser
92+
## Modem Credentials Parser
93+
9194
The script above, `device_credentials_installer` makes use of this script, `modem_credentials_parser`, so if you use the former, you do not need to also follow the directions below. If `device_credentials_installer` does not meet your needs, you can use `modem_credentials_parser` directly to take advantage of additional options.
9295

9396
This script parses the output of `AT%KEYGEN` and `AT%ATTESTTOKEN`. Each command outputs two base64 strings joined by a `.` character. The first string is the command specific data. The second string is the [COSE](https://datatracker.ietf.org/doc/html/rfc8152) signature of the first string.
@@ -257,7 +260,8 @@ File created: /my_devices/pem_files/hw_rev2-50363154-3931-44f0-8022-121b6401627d
257260
File created: /my_devices/pem_files/hw_rev2-50363154-3931-44f0-8022-121b6401627d_17_pub.pem
258261
```
259262

260-
# Create Device Credentials
263+
## Create Device Credentials
264+
261265
The script above, `device_credentials_installer` makes use of this script, `create_device_credentials`, so if you use the former, you do not need to also follow the directions below.
262266
If `device_credentials_installer` does not meet your needs, you can use `create_device_credentials` directly to take advantage of additional options.
263267

@@ -292,17 +296,18 @@ File created: /dev_credentials/hw_rev2-50363154-3931-44f0-8022-121b6401627d_pub.
292296
```
293297

294298
## Claim and Provision Device
299+
295300
This script uses the [nRF Cloud Identity and Provisioning API](https://api.provisioning.nrfcloud.com/v1/) to perform remote device provisioning tasks.
296-
This service is only compatible with nRF91x1 devices running modem firmware >= 2.0.0.
301+
302+
### Limitation
303+
304+
- This script is **not supported for nRF9160 devices.**
305+
- This service is only compatible with nRF91x1 devices running modem firmware >= 2.0.0.
306+
- Since this process takes some time, it is not recommended in a production setting.
307+
- For a production setting, it's better to use `gather_attestation_tokens` (see below).
297308

298309
After claiming and provisioning, this script will onboard the device to your nRF Cloud account.
299-
The target device must be running the [nRF Device Provisioning](https://github.com/nrfconnect/sdk-nrf/tree/main/samples/cellular/nrf_provisioning) sample built with the following options:
300-
```
301-
CONFIG_AT_SHELL=y
302-
CONFIG_NRF_PROVISIONING_RX_BUF_SZ=2048
303-
CONFIG_SHELL_BACKEND_SERIAL_RX_RING_BUFFER_SIZE=2048
304-
CONFIG_SHELL_CMD_BUFF_SIZE=2048
305-
```
310+
The target device must have the Provisioning feature enabled. A good reference on how to integrate this is the [nRF Device Provisioning](https://github.com/nrfconnect/sdk-nrf/tree/main/samples/cellular/nrf_provisioning) sample.
306311

307312
When not using provisioning tags (with the `--provisioning-tags` argument), this script creates device credentials for use with nRF Cloud and so requires a CA certificate and the associated private key as an input.
308313

@@ -314,18 +319,18 @@ Use `--help` for additional parameter information.
314319

315320
#### Device certificate created locally from CSR received over the air:
316321

317-
It's recommended to use the `nrf_cloud_multi_service` sample with the provisioning overlay for this.
318-
Since this process takes some time, it is not recommended in a production setting.
319-
For a production setting, it's better to use `gather_attestation_tokens` (see below).
322+
It's recommended to use the [nRF Device Provisioning](https://github.com/nrfconnect/sdk-nrf/tree/main/samples/cellular/nrf_provisioning) sample for this.
323+
320324
```
321-
claim_and_provision_device --api-key $API_KEY --ca=./ca.pem --ca-key=ca_prv_key.pem --cmd-type at_shell
325+
claim_and_provision_device --api-key $API_KEY --ca=./ca.pem --ca-key=ca_prv_key.pem
322326
```
323327
Query the device for its attestation token over USB, claim the device with the REST API, then provision over the air up to receiving the CSR.
324328
Create the device certificate locally, then send back to the device over the air.
325329

326330
#### Claim device and use a provisioning tag to fully provision and onboard it
331+
327332
```
328-
claim_and_provision_device --api-key $API_KEY --provisioning-tags "nrf-cloud-onboarding" --cmd-type at_shell
333+
claim_and_provision_device --api-key $API_KEY --provisioning-tags "nrf-cloud-onboarding"
329334
```
330335
Like before, but use a built-in provisioning tag so the device certificate is created by the cloud and then sent to the device over the air.
331336

@@ -343,18 +348,15 @@ The collected data, along with the current date and time, is saved to a CSV file
343348
### Limitation
344349

345350
- This script is **not supported for nRF9160 devices.**
351+
- This service is only compatible with nRF91x1 devices running modem firmware >= 2.0.0.
346352

347353
### Examples
348354

349-
* #### Gather attestation tokens using AT Commands
355+
* #### Gather attestation tokens
350356
```bash
351357
gather_attestation_tokens
352358
```
353359

354-
* #### Gather attestation tokens using Shell Commands (e.g. Multi Service Sample)
355-
```bash
356-
gather_attestation_tokens --coap --cmd-type at_shell
357-
```
358360
## Claim Devices
359361

360362
Use the `claim_devices` script to claim devices by sending the contents of a CSV file to the nRF Cloud REST API, along with a specified set of provisioning tags. By default, the script looks for a file named `attestation_tokens.csv`. If you want to use a different file, you can specify it using the `--csv` option followed by the file name.
@@ -428,3 +430,36 @@ The script can run in two modes:
428430
```bash
429431
nrf_cloud_device_mgmt --api-key $API_KEY
430432
```
433+
434+
## nRF Credential Store
435+
436+
`nrfcredstore` is a command-line tool that simplifies the management of credentials stored in nRF91 modems.
437+
438+
It supports the following subcommands:
439+
440+
list List all keys stored in the modem
441+
write Write key/cert to a secure tag
442+
delete Delete value from a secure tag
443+
deleteall Delete all keys in a secure tag
444+
imei Get IMEI from the modem
445+
attoken Get attestation token of the modem
446+
generate Generate private key
447+
448+
### Examples
449+
450+
* #### List all keys stored in the modem
451+
```bash
452+
nrfcredstore /dev/ttyACM0 list
453+
```
454+
455+
* #### Delete sectag 42, Key type ROOT_CA_CERT
456+
```bash
457+
nrfcredstore /dev/ttyACM0 delete 42 ROOT_CA_CERT
458+
```
459+
460+
* #### Delete all keys in the modem, similar to a factory reset.
461+
```bash
462+
nrfcredstore /dev/ttyACM0 deleteall
463+
```
464+
465+
More information can be found on the [nrfcredstore GitHub page](https://github.com/NordicSemiconductor/nrfcredstore/tree/main)

README.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ Run the following command to use this package as a dependency:
4646
# Enable modem-based JSON Web Token (JWT) generation required for nRF Cloud authentication
4747
CONFIG_MODEM_JWT=y
4848
49-
# Configure the nRF Cloud library to use the device's internal UUID as the client ID
49+
# Configure the nRF Cloud library to use the device's internal UUID
5050
CONFIG_NRF_CLOUD_CLIENT_ID_SRC_INTERNAL_UUID=y
51-
52-
# Define the modem security tag where nRF Cloud credentials will be stored (16842753 is the standard tag used by Nordic examples)
53-
CONFIG_NRF_CLOUD_SEC_TAG=16842753
51+
# Or IMEI as the device ID
52+
CONFIG_NRF_CLOUD_CLIENT_ID_SRC_IMEI=y
53+
# But not both at the same time
5454
```
55-
**Failure to include these settings will prevent the device from connecting to nRF Cloud.**
55+
:warning:**Failure to include these settings will prevent the device from connecting to nRF Cloud.**
5656
5757
## How-To: Registering devices quickly
5858
@@ -62,9 +62,18 @@ Start by creating a local certificate authority (CA). Its contents won't be chec
6262
6363
Now, you should have three `.pem` files containing the key pair and the CA certificate of your CA. The files have a unique prefix.
6464
65-
To get your device registered is using the `device_credentials_installer` script:
65+
To get your device registered, use the `device_credentials_installer` script. Be aware of which device ID is your project using, as it can be either a UUID or an IMEI. Depending on your device ID type, use one of the following commands:
66+
67+
#### UUID
68+
```
69+
device_credentials_installer -d --ca ./ca.pem --ca-key ./ca_prv_key.pem --verify
70+
```
6671
67-
device_credentials_installer -d --ca *_ca.pem --ca-key *_prv.pem --coap --verify
72+
#### nrf-\<IMEI\>
73+
```
74+
device_credentials_installer -d --ca ./ca.pem --ca-key ./ca_prv_key.pem --verify --id-imei --id-str nrf-
75+
```
76+
:warning:**Failure to select the correct device ID will result in a connection refused from nRF Cloud.**
6877
6978
Upon success, you can find an `onboard.csv` file with information about your device. This file is needed to register the certificate with your account.
7079
If you encounter a `No device found` error, you might need to specify the serial port using the `--port` option.

0 commit comments

Comments
 (0)