Skip to content

Signed firmware

To make ESP32 devices reject tampered or unsigned OTA updates, sign each application binary with an Ed25519 private key that only you hold, and pin the matching public key in the firmware. SimpleOTA refuses an upload whose signature does not verify against your project's key. The device checks the signature again over the bytes it downloaded, before it marks the new image bootable. A device that fails the check keeps running its current firmware and reports signature_invalid. Even if your SimpleOTA account or a CI token is compromised, devices will not boot a binary that was not signed with your key.

# Once: create the key pair, then register public.pem with your project.
openssl genpkey -algorithm ed25519 -out private.pem
openssl pkey -in private.pem -pubout -out public.pem

# Every release: sign the exact bytes you upload.
openssl pkeyutl -sign -inkey private.pem -rawin -in firmware.bin | base64 -w0 > firmware.sig

On the device, the Arduino and ESP-IDF clients verify the signature for you once you set security_mode to signed and pin up to two public keys. The sections below cover each step, CI signing and key rotation.

This check runs in your application, so it protects the update path, not the device itself. Someone with physical access can still flash other firmware over USB, and firmware that is already compromised does not check itself. For those threats you also need ESP32 Secure Boot v2, which is available under ESP-IDF but not with the stock Arduino cores; see This is not Secure Boot for how the two fit together.

How the trust chain works

  1. You register a public key with your project. Generate the Ed25519 keypair in your browser on the signing keys page, or locally with openssl. SimpleOTA stores only the public key, and a browser-generated private key is shown once after registration succeeds without ever reaching the server.
  2. Your build pipeline signs the raw firmware binary bytes and uploads binary + signature. SimpleOTA verifies the signature against the project's key before accepting the artifact.
  3. At OTA check time, eligible devices receive the signature alongside the pre-signed download URL.
  4. The device writes the image while it downloads and hashes it as it goes, then marks it bootable only after the SHA-256 matches the offer's checksum. It checks the signature only when a public key is pinned.

Step 4 is what makes the guarantee real. Server-side verification alone cannot protect a device from a compromised delivery path; on-device verification can.

1. Create a signing key

Dashboard: Project (Advanced mode) → Firmware signing keys → New key. Generate key in this browser creates the Ed25519 keypair with WebCrypto and submits only the key id and the public key. After the server confirms registration, the private key is shown once so you can copy it or download simpleota-signing-key.pem. SimpleOTA does not keep a copy. If that browser cannot generate an Ed25519 key, the button stays disabled. Generate a keypair locally and paste the public key:

openssl genpkey -algorithm ed25519 -out simpleota-signing-key.pem
openssl pkey -in simpleota-signing-key.pem -pubout

API: the create call registers a public key you already hold. A request without public_key_pem is rejected with HTTP 400. The response has no private key.

openssl genpkey -algorithm ed25519 -out simpleota-signing-key.pem
openssl pkey -in simpleota-signing-key.pem -pubout -out public.pem
PUBLIC_KEY_PEM=$(awk '{printf "%s\\n", $0}' public.pem)
curl -X POST https://simpleota.com/api/v1/projects/$PROJECT_ID/signing-keys/ \
  -H "Authorization: Bearer $SIMPLEOTA_TOKEN" \
  -H "Content-Type: application/json" \
  -d "{\"key_id\":\"prod-2026\",\"public_key_pem\":\"${PUBLIC_KEY_PEM}\"}"

Keep a backup key

SimpleOTA only keeps the public half of your signing key. If you generated the keypair in the browser, you see the private key once, so save that PEM somewhere safe straight away, like a password manager or an encrypted offline backup. Keep it out of your firmware repository and your CI logs.

Your devices only trust the public keys built into the firmware they're running (two at most), and the server never sends them new ones. If you lose the private key, nothing you sign from then on verifies on devices that only trust that key, so they turn down every update and stay on the firmware they have.

There are two ways back from that:

  • Upload a binary you signed with the lost key before you lost it, as long as its firmware pins a key you still hold. Every upload gets a new, higher build number, so devices accept it. Hold off on revoking the lost key until that upload is done, because the server rejects uploads signed with a revoked key.
  • Reflash each device over USB when you have no such binary.

It's much easier to never end up there. Add a spare key while you can still sign with the first one:

  1. Generate a second Ed25519 keypair, register its public half on your project under a new key id, and store its private key as carefully as the first.
  2. Ship one update signed with the first key. Its firmware pins both public keys, with their key ids, in cfg.signing_keys, sets cfg.num_signing_keys = 2, and keeps cfg.security_mode = SIMPLEOTA_SECURITY_SIGNED.

Once your devices run that update, they accept releases signed with either key.

The spare takes the second of the two key slots, so when you rotate in a new key later, ship an update that pins the key you're keeping plus the new one. See Key rotation and revocation.

2. Sign and upload

No CI yet? Sign in your browser

The dashboard upload form has a Sign in browser helper: pick your binary, select a signing key from the dropdown, paste your private key PEM, and the signature is computed locally via WebCrypto. The private key field is never part of the form submission, so the key stays on your machine. This is the easiest path while you set up CI.

Trade-off, stated plainly: browser signing means trusting the page's JavaScript at signing time. For commercial fleets, sign in CI where the key lives in a proper secret store.

The signature covers the raw binary bytes, exactly as uploaded (and exactly as later delivered to devices).

SIGNATURE=$(openssl pkeyutl -sign -inkey private.pem -rawin -in firmware.bin | base64 -w0)

cat > manifest.json <<EOF
{
  "framework": "arduino",
  "version_label": "2.1.0",
  "chip_family": "esp32",
  "security_mode": "signed",
  "signing_metadata": {
    "key_id": "prod-2026",
    "algorithm": "ed25519",
    "signature": "$SIGNATURE"
  }
}
EOF

curl -X POST https://simpleota.com/api/v1/projects/$PROJECT_ID/artifacts/ \
  -H "Authorization: Bearer $SIMPLEOTA_TOKEN" \
  -F "manifest=<manifest.json" \
  -F "binary=@firmware.bin"

Uploads with a missing or invalid signature, an unknown or malformed key_id, or a revoked key are rejected with a 400 and a specific error message. A valid key_id is 1 to 64 characters long, uses only letters, digits, ., _ and -, starts with a letter or digit, and has no surrounding whitespace. No build number is consumed by a rejected upload.

3. OTA check response

For a signed artifact, eligible devices receive three extra fields:

{
  "update_available": true,
  "build_number": 12,
  "url": "https://firmware.simpleota.com/...",
  "checksum": "8f3c...",
  "size": 1287456,
  "security_mode": "signed",
  "signing_key_id": "prod-2026",
  "signature_algorithm": "ed25519",
  "signature": "<base64>"
}

4. Verify on the device (required)

Pin the public key in your firmware (it is not a secret). Verify after download, before the image can boot.

Arduino: built into SimpleOTAClient 1.0

The SimpleOTAClient library does this for you. Pin the key and advertise signed mode; every signed offer is then verified over the exact downloaded bytes, streamed during download, before the image is marked bootable:

static const char *PUBKEY_PEM =
    "-----BEGIN PUBLIC KEY-----\n"
    "MCowBQYDK2VwAyEA...your project public key...\n"
    "-----END PUBLIC KEY-----\n";

const simpleota_signing_key_t keys[] = {
    {.key_id = "prod-2026", .pem = PUBKEY_PEM},
};
simpleota_config_t cfg = {};
cfg.security_mode = SIMPLEOTA_SECURITY_SIGNED;
cfg.signing_keys = keys;
cfg.num_signing_keys = 1;

A tampered or unapproved image is rejected (simpleota_apply() returns SIMPLEOTA_SIGNATURE_FAIL), the device keeps running its current firmware, and a failed event with reason signature_invalid appears on the dashboard device row. During key rotation, pin up to two keys in signing_keys. See the library's examples/SignedOTA sketch.

ESP-IDF and custom integrations: manual verification

On ESP-IDF, the easy path is the first-party wassie-dev/simpleota component: pin the key via simpleota_config_t.signing_keys and verification happens automatically, incrementally, during download.

For a hand-rolled integration, note that mbedTLS does not implement Ed25519, on any ESP-IDF version; you need a standalone implementation. The SimpleOTA clients vendor Monocypher 3.1.3 (the last release with the incremental crypto_ed25519_check_init/update/final API, which lets you verify while streaming so the image never has to fit in RAM):

#include "monocypher-ed25519.h"

// pub: your project's raw 32-byte public key (decoded from the PEM's
// fixed-layout SPKI: the final 32 bytes of the base64-decoded body).
// sig: raw 64 bytes, base64-decoded from the OTA response.
crypto_check_ed25519_ctx ctx;
crypto_ed25519_check_init((crypto_check_ctx_abstract *)&ctx, sig, pub);
// for each downloaded chunk, in order:
crypto_ed25519_check_update((crypto_check_ctx_abstract *)&ctx, chunk, len);
// after the last chunk, BEFORE marking the partition bootable:
bool ok = crypto_ed25519_check_final((crypto_check_ctx_abstract *)&ctx) == 0;

Compact one-shot alternatives such as ed25519-donna or c25519 also work if you can buffer or re-read the image.

When verification fails, do not mark the image bootable. Report it so the dashboard (and any watching automation) sees the failure for what it is:

POST /api/v1/ota/status/
{ "deployment_id": "…", "event": "failed", "reason": "signature_invalid" }

signature_invalid is the canonical reason token for this case; see the failure and rollback reasons.

Verify before the image can boot

If your device marks an image bootable without verifying, the signed mode gives you no more protection than basic. The whole point of the signature is that the device refuses unapproved images even when everything upstream of it is compromised.

If your image is too large to buffer in RAM, verify incrementally with the streaming API shown above (this is what both SimpleOTA clients do), or stream the image to the inactive OTA partition first and verify by reading it back before marking it bootable.

Migrating a fleet from basic to signed

The server only offers an artifact to a device whose reported security_mode matches the artifact's (exactly, or when either side is blank); see how modes are matched. Keys are compiled into the firmware, not stored on the device. Both facts shape the migration:

  1. Ship one final basic upload whose firmware pins the public key in cfg.signing_keys and sets cfg.security_mode = SIMPLEOTA_SECURITY_SIGNED. A basic artifact reaches devices reporting basic and devices that never reported a mode, so the whole fleet gets it regardless of history.
  2. Devices running the new firmware report security_mode: "signed" and verify every subsequent update on-device.
  3. From then on, upload only signed artifacts. The matching rule is symmetric: a signed device is never offered a basic artifact, so there is no quiet fallback to unsigned releases.

Do not try to migrate by uploading the new firmware as a signed artifact: devices explicitly reporting basic will never be offered it, and devices that would accept it cannot verify it yet anyway. The device's mode is changed by the firmware it runs, not by the mode of the artifact that delivered it. Changing security modes covers the other moves, including going back to basic, and how to run the hop as a canary.

Watch for stragglers

A device blocked by mode mismatch does not error; it receives a normal no_compatible_build response and silently stays on its current build. After migrating, check the project device list for devices still reporting basic (stuck on an old build) before you stop publishing the migration artifact.

Turn on strict mode

A signed image proves who built the firmware. It does not prove which build number it was released as, because SimpleOTA assigns the number after you sign. Strict mode covers that: each release also carries a strict signature over the project, the key, the build number and the image's SHA-256, and a device in strict mode refuses an offer without one. A build that has it is strict-ready.

Strict mode needs SimpleOTAClient 1.2.0 or later on Arduino (see its StrictOTA example), or the wassie-dev/simpleota component 1.2.0 or later on ESP-IDF (its signed example has a "Strict signing" choice in menuconfig).

Release with the SimpleOTA CLI 0.2.0 or later, or the GitHub Actions v1.1.0 or later. Both make signed builds strict-ready, and nothing else about releasing changes. The actions do this as a best-effort step that only warns when it fails (see Strict mode for the fix):

simpleota release build/app.bin --version-label 1.4.0

Then switch the fleet over in three steps:

Check the project id and key before step 2

A strict device with a wrong project id or key refuses every later offer, and only a USB reflash brings it back. See Changing security modes for how to rehearse the project id in signed mode first.

  1. Release with the CLI or the GitHub Actions from now on.
  2. Ship one firmware release that turns strict mode on. Set your project id and the mode next to your pinned keys. The snippet simpleota key generate prints ends with the project id line, commented out.

    cfg.project_id = "11111111-1111-4111-8111-111111111111";
    cfg.security_mode = SIMPLEOTA_SECURITY_STRICT;
    

    Both lines are needed. The project id alone does not turn strict mode on, and only strict mode stops a replayed build.

  3. Keep releasing the same way. Devices that took step 2 show "strict signing" on their device page and are offered strict-ready builds only.

A build that is not strict-ready still deploys to the rest of the fleet. Strict devices are left out of it and stay on their current build. A strict device it would otherwise update gets the status its check-in would have anyway (no_compatible_build, up_to_date or not_in_rollout) with a message that a build is deployed but is not strict-ready. A strict device offered an older strict-ready build gets that offer with no message, and the message once it runs that build. To make an earlier signed build strict-ready, run simpleota build make-strict <build-number> <bin> with the build's own binary.

Which release paths are strict-ready

Release path Signed Strict-ready
SimpleOTA CLI 0.2.0+ (simpleota release, simpleota build upload) Yes Yes
GitHub Actions v1.1.0+ with signing-key Yes Yes, unless the best-effort step failed (the job still passes with a warning)
Dashboard upload form, with or without Sign in browser Yes No
Raw API calls with openssl and curl, including the GitLab CI job Yes No

A strict release cannot be made from the dashboard. The strict signature is made with your private key after SimpleOTA assigns the build number, and the key stays on your machine or in your CI secrets, so the step runs there. A build uploaded another way is still offered to devices in signed mode, and simpleota build make-strict <build-number> <bin> makes it strict-ready afterwards. In any CI system, install the CLI and give it the key in SIMPLEOTA_SIGNING_KEY; see the CLI in CI.

To move devices from basic straight to strict mode, to rehearse strict mode in signed first, or to turn strict mode off again, see Changing security modes.

Key rotation and revocation

  • A project can hold multiple keys. Each artifact records which key_id signed it, shown as a badge in the dashboard.
  • Revoking a key (dashboard or DELETE /api/v1/projects/{id}/signing-keys/{key_id}/) immediately blocks new uploads signed with it. Artifacts already verified with it remain servable, so in-flight rollouts are not disrupted.
  • To rotate: create key-2027, update your CI secret and device firmware (pin both keys during the transition), then revoke key-2026.

Threat model, honestly stated

Signing protects devices from flashing binaries that you did not approve: a compromised SimpleOTA account, a leaked upload token, or a tampered storage object all fail device-side verification. It does not protect against a compromised build pipeline that holds your private key, and it is not a substitute for keeping upload credentials out of device firmware. Keep the private key in a secret store with the narrowest possible access.

This is not Secure Boot

Do you need Secure Boot if you already verify a signature on OTA updates? Yes, if your threat model goes beyond the OTA delivery path. A signature check on OTA updates stops a tampered build that arrives over the network. It runs inside the application, so it cannot help once someone reflashes the device over USB, or once the running firmware is compromised. Secure Boot stops an unsigned image from booting, however it got onto the flash. Secure Boot cannot be enabled on the Arduino path, because the stock cores ship bootloaders built without it; build under ESP-IDF if you need it.

Verification runs inside the application, so the trust anchor is the firmware the device is already running. That protects the OTA delivery path; it does not protect the device itself:

  • Physical access defeats it. Every ESP32 ships with a ROM download mode: an attacker with the device in hand can reflash arbitrary firmware over UART/USB with esptool. The OTA-level check never runs.
  • Already-compromised firmware defeats it. Code that is running does not verify itself.

The hardware answer to those threats is ESP32 Secure Boot (v2): an eFuse-burned key makes the ROM verify the bootloader and the bootloader verify the application on every boot, so physically reflashed unsigned images will not boot (add Flash Encryption to also prevent firmware readout). It is irreversible and adds toolchain complexity, which is why it is a deliberate opt-in.

The two compose cleanly and answer different questions: SimpleOTA signing protects the supply chain to the device; Secure Boot protects the device itself. Fleets facing physical attackers should run both. SimpleOTA signing still adds value alongside Secure Boot: it rejects a bad image before the reboot/rollback cycle and reports signature_invalid to the dashboard, giving you a fleet-level tamper signal that silent bootloader rejection does not.

Using SimpleOTA with Secure Boot enabled

No SimpleOTA configuration is needed: Secure Boot v2 signatures are appended to the .bin itself, and SimpleOTA stores, checksums, signs, and delivers those exact bytes untouched. Two things to get right:

  1. Signing order in CI. The SimpleOTA Ed25519 signature must cover the final, shippable bytes: build -> secure-boot sign (espsecure) -> SimpleOTA sign -> upload. A SimpleOTA signature made before the secure-boot step does not match the bytes you upload, and the upload is rejected.
  2. Failure semantics. An image that fails Secure Boot verification is rejected by esp_ota_set_boot_partition(); on Arduino this surfaces as a failed event with reason update_end_failed (not signature_invalid, which is reserved for the SimpleOTA Ed25519 check).

On Arduino 1.0, trial rollback uses the ESP32 bootloader's rollback path unless you build with -DSIMPLEOTA_DISABLE_BOOTLOADER_ROLLBACK. If you also enable ESP-IDF anti-rollback (eFuse secure_version), an image below the eFuse counter will not boot. Secure Boot needs an ESP-IDF build, because the stock Arduino cores ship precompiled bootloaders without it.

The shared client core checks build numbers before signature verification: a signed offer at or below the running build is refused as downgrade_refused and is never downloaded.