Skip to content
Contents
GuidesOpenWrt

Does your OpenWrt upgrade backup include the LuCI HTTPS certificate and key?

Keeping settings can preserve the uHTTPd configuration while missing a custom key. Before running owut, check three actual archive entries and compare the public certificate hashes.

Keeping settings can preserve the uHTTPd configuration while missing a custom key. Before running owut, check three actual archive entries and compare the public certificate hashes.

Find the HTTPS instance

This example uses LuCI served directly by uHTTPd on OpenWrt 25.12.6. Over trusted SSH, check the paths. If a proxy terminates TLS, check its certificate separately. Replace both instances of main as needed. Resolve links with readlink -f and back up their targets.

uci show uhttpd | grep -E '\.(cert|key)='

Inspect a temporary backup

Check free space in /tmp first. Run the block together. It creates a private archive, prints paths and public certificate hashes, then cleans up. It does not flash firmware. Keep the archive and private key confidential.

(
  set -eu
  umask 077
  cert=$(uci get uhttpd.main.cert)
  key=$(uci get uhttpd.main.key)
  test -f "$cert" && test -f "$key" || exit 1
  d=$(mktemp -d /tmp/cert-check.XXXXXX)
  trap 'rm -f "$d/b.tgz" "$d/list" "$d/public"; rmdir "$d"' EXIT
  sysupgrade -b "$d/b.tgz"
  tar -tzf "$d/b.tgz" > "$d/list"
  for p in /etc/config/uhttpd "$cert" "$key"; do
    grep -Fx "${p#/}" "$d/list"
  done
  tar -xzOf "$d/b.tgz" "${cert#/}" > "$d/public"
  test -s "$d/public"
  sha256sum "$cert" "$d/public"
)

SSH · OpenWrt 25.12.6 · sysupgrade · SHA-256

The SSH capture is from an isolated VM. Look for the configuration, certificate and key, then two equal hashes. If execution stops, check the last step. For missing files, confirm the paths, append one absolute path per line to /etc/sysupgrade.conf without replacing existing entries, and repeat. Save external targets and renewal settings separately.

Keep a separate recovery copy

Download a fresh backup under System → Backup / Flash Firmware. Store it encrypted and check this final copy too. In a new private directory on a trusted computer, extract only the needed files. Name the PEM copies cert.pem and key.pem below. For DER add -inform DER to the corresponding command.

openssl x509 -in cert.pem -pubkey -noout > cert.pub &&
openssl pkey -in key.pem -pubout > key.pub &&
cmp cert.pub key.pub && echo MATCH

MATCH confirms the public keys agree. Postpone the upgrade if files are missing, unreadable or mismatched. Afterwards check the fingerprint and login at the original hostname. For an unexpected change, check mounts and the serving instance, restore matching files, permissions and settings through your backup access, then reload uHTTPd and retest.

Does an OpenWrt backup contain Wi-Fi and PPPoE passwords? Check without printing them

Explore hardware

Comments