Skip to main content
Every fwup firmware file carries an Ed25519 signature made with a private key you hold. The signature is checked twice: by NervesHub when you upload, and by fwup on the device before anything is written. A device refuses firmware it cannot verify. This page covers fwup firmware and archives. ESP-IDF and RAUC use different key types, described in ESP-IDF and RAUC.

Where the signature is checked

Only the private key can sign. Keep it out of source control, and out of the firmware.

Create and register a key

Signing keys belong to an organization. Every product in the organization shares them.
This generates the key pair, uploads the public key, and saves both halves under ~/.nh/keys/<org>/ as my_app_key.priv and my_app_key.pub. The private key file is encrypted at rest, with an optional passphrase.
You can also add a public key in the web UI, on the organization’s Signing keys page. Choose the fwup (Ed25519) scheme and paste the base64 public key. nh key list prints each Ed25519 public key in full. That value is what goes into fwup_public_keys.

Give devices the public keys

A device needs at least one public key before it accepts an update.

Put the keys in the firmware

List the base64 public keys in your firmware config:
The device accepts firmware signed by any key in the list. Entries that are not strings are ignored. With keys configured this way, the device does not ask NervesHub for keys. Since nerves_hub_link 2.14.0 it also ignores any keys NervesHub sends without being asked. Verification then depends only on what you built into the firmware. Changing the list means shipping new firmware, signed by a key the running firmware already trusts.

Ask NervesHub for the keys

A device with no fwup_public_keys asks NervesHub for keys each time it connects. NervesHub replies with all of the organization’s Ed25519 public keys. This needs nerves_hub_link 2.2.1 or later. To request keys even when some are configured, set request_fwup_public_keys:
When NervesHub replies with keys, they replace the configured list in memory. When it replies with none, the device keeps the keys it has.
Requested keys come from the same server that supplies the firmware. The signature check then tells you the firmware matches a key NervesHub knows, not a key you built into the device. Put the keys in the firmware if you want verification that does not depend on the server.

Unverifiable firmware is refused

Since nerves_hub_link 2.13.0, a device with no usable public key refuses the update. fwup only checks a signature when it is given a key, so earlier versions applied the firmware unverified. The refusal happens before update_available/1 is called, so your Client is not asked. The device logs:
It also reports the update to NervesHub as failed, with the reason Refusing unverified firmware : no public keys available.
A device that has no fwup_public_keys and receives none from NervesHub stops taking updates on 2.13.0 and later. Before you upgrade nerves_hub_link, check that every device either has keys configured or belongs to an organization with at least one Ed25519 signing key.
Two related changes tighten how keys from the server are handled: When a signature does not match any key the device holds, fwup fails and the update is reported as failed. See failed updates.

Sign firmware

nh firmware upload signs before it uploads:
See Firmware for the other ways to supply the key. To upload a file that is already signed, pass --skip-signing. NervesHub still verifies the signature. To sign without uploading, use fwup directly:

Use more than one key

  • Separate development and production. Sign release builds with a production key held only by your release pipeline. Build production firmware with only the production public key in fwup_public_keys. Development-signed firmware then cannot be installed on production devices.
  • Rotate a key. Ship firmware that lists both the old and the new public key, signed with the old key. Once devices run it, sign later firmware with the new key. Remove the old public key from the list in a later release.
Removing a key from fwup_public_keys only affects devices that receive the firmware built without it.

Archive keys

Archives are verified the same way, with their own key list. See Archives for archive_public_keys and request_archive_public_keys.