Securely onboard a device¶
Use secure device onboarding to register an Ubuntu Core device with a Dedicated Snap Store using a per-device hardware identity, rather than a shared model API key.
Prerequisites¶
Before onboarding a device, ensure that you have:
configured a Model Service with a serial-signing key, model, and policy,
configured that model to use hardware-identity provisioning, and
a gadget snap that implements the
prepare-deviceandprepare-serial-requesthooks.
See Configure Model Service for the general Model Service setup.
Prepare the gadget snap¶
Implement the following hooks in the gadget snap for the device model:
prepare-devicegenerates a unique hardware identity key pair and stores its private key securely, preferably in a TPM or HSM. It must also make the public key available to your manufacturing process.prepare-serial-requestreceives a nonce from snapd, signs it with the hardware identity private key, and returns the hardware key digest and nonce signature in the serial-request body.
For the required hook behaviour and request format, see the prepare-device hook documentation and the prepare-serial-request hook documentation.
Provision the hardware identity¶
For each device, complete the following steps:
Boot the device with an image containing the gadget snap. The
prepare-devicehook generates the hardware identity key pair.Keep the private key on the device. Do not export or reuse it for another device.
Export the public key and create a signed hardware-identity assertion for the device.
Import the hardware-identity assertion into the Model Service before the device first boots its production image. Import assertions in bulk where appropriate.
Onboard the device¶
Build and install the production Ubuntu Core image without a model API key. Configure the gadget’s
device-service.urlto point to the Model Service.Start the device and allow Ubuntu Core to complete seeding. snapd requests a nonce from the Model Service and runs
prepare-serial-request.The hook signs the nonce with the device’s hardware identity private key. snapd sends the signature and hardware key digest in its serial assertion request.
The Model Service verifies the signature against the imported hardware-identity assertion and issues a serial assertion for the device.
Verify onboarding¶
After seeding completes, run the following on the device:
snap model --assertion
snap model --serial --assertion
The first command confirms the expected model assertion. The second command must return the device serial assertion, confirming that onboarding succeeded.
If onboarding fails, inspect the failed seeding change with snap changes.
Confirm that the correct hardware-identity assertion was imported, the gadget
hook can access the private key, and the device can reach the Model Service.