Sign the app update feed with Ed25519 and verify it in the app

Each installation generates a private Ed25519 key once (0600, under
~/.config/pipelines), signs version.json with a detached version.json.sig
when publishing APK and desktop builds, and embeds its own and listed
trusted public keys in app builds. The app verifies the feed signature
before trusting the artifact sha256, refuses unsigned or foreign feeds when
it has keys, and requires the sha256 and Android signer in signed feeds.
This commit is contained in:
2026-11-10 00:51:16 +00:00
parent a706739088
commit 9f38e38f6a
17 changed files with 1010 additions and 26 deletions
+10 -5
View File
@@ -120,8 +120,8 @@ def _macos_build(*, app, cache, source_digest, runner, arguments, flutter, log):
def build_desktop(kind, *, app, cache, runner, source_digest, docker_build,
docker_ready, server_url=None, flutter=None, output=None, log=print,
prune_cache=None):
arguments = _arguments(server_url)
prune_cache=None, update_keys=()):
arguments = _arguments(server_url) + tuple(update_keys)
if kind == "macos":
entry, bundle, archive = _macos_build(app=app, cache=cache, runner=runner,
source_digest=source_digest, arguments=arguments, flutter=flutter, log=log)
@@ -154,8 +154,10 @@ def build_desktop(kind, *, app, cache, runner, source_digest, docker_build,
return bundle, archive
def publish_desktop(kind, bundle, archive, updates, *, notes="", log=print):
"""Publish archive before its feed; versioned names preserve in-flight reads."""
def publish_desktop(kind, bundle, archive, updates, *, signer, notes="", log=print):
"""Publish archive before its feed; versioned names preserve in-flight reads.
[signer] returns the detached `version.json.sig` for the feed bytes."""
entry = bundle.parent if kind == "macos" else bundle
complete = json.loads((entry / ".complete").read_text())
code = int(complete["built"]) // 60
@@ -176,8 +178,11 @@ def publish_desktop(kind, bundle, archive, updates, *, notes="", log=print):
previous = json.loads(feed.read_text())
if previous.get("versionCode", 0) > code:
raise ValueError("Refusing to publish an older build over a newer update")
data = (json.dumps(metadata) + "\n").encode()
# The signature lands before the feed it covers, after the archive.
for destination, content in ((target / filename, archive.read_bytes()),
(feed, (json.dumps(metadata) + "\n").encode())):
(target / "version.json.sig", signer(data)),
(feed, data)):
descriptor, temporary = tempfile.mkstemp(prefix=destination.name + ".", dir=target)
try:
with os.fdopen(descriptor, "wb") as output: