.fw file against a public key that was compiled into the firmware at build time. This verification happens entirely on the device — independently of NervesHub — so the chain of trust holds even if the server or the network is compromised.
How It Works
Signing happens inside thefwup tool that packages Nerves firmware, using a public/private key pair you create. The signature is then checked in two places:
- At build time, you embed the public key into your firmware image via the
fwup_public_keysconfiguration. Every device that runs that firmware will only accept OTA updates signed by the corresponding private key. - When you upload firmware to NervesHub, the server checks the signature against the public keys registered for your product. Unsigned firmware or firmware signed by an unregistered key is rejected at upload time.
Creating a Signing Key
Use thenh CLI to generate a keypair and register the public key with your NervesHub product in one step:
nh configuration directory — treat it with the same care as any other secret credential.
Embedding the Public Key in Firmware
For a device to verify firmware signatures independently, the public key must be compiled into the firmware image at build time. Add the base64-encoded public key to yourconfig/target.exs:
"base64_encoded_public_key_here" with the value shown for your key. Rebuild and re-flash any devices that need to accept firmware signed by the new key — the embedded public keys are part of the firmware itself and cannot be updated over the air without a matching signed update.
Signing and Uploading Firmware
Once you have a signing key registered, sign your firmware and upload it to NervesHub in a single command:.fw file with the private key associated with my-key and then uploads the signed binary to NervesHub. The server verifies the signature against the registered public key before accepting the upload.
Using Multiple Signing Keys
Maintaining more than one signing key is a best practice for production fleets. A common setup uses two keys:- Production key — tightly controlled; used only in your release pipeline; private key stored in a secrets manager or HSM.
- Development key — used for internal builds and QA; acceptable to store in developer workstations.
-
Register each key with NervesHub:
-
Embed all accepted public keys in your firmware. A device will accept firmware signed by any of the keys listed in
fwup_public_keys: -
Sign each firmware with the appropriate key for its intended audience:
fwup_public_keys in your production Mix target), ensuring that development-signed firmware cannot be installed on production hardware even if an attacker gains access to the dev key.
Removing a public key from
fwup_public_keys and rebuilding only affects devices that receive the new firmware. Devices still running older firmware will continue to accept the keys that were embedded when that firmware was built.
