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
+15 -3
View File
@@ -160,24 +160,36 @@ class DesktopBuildTests(unittest.TestCase):
def test_linux_publication_has_matching_hash_and_rejects_downgrade(self):
bundle, archive = self.build("linux")
updates = self.root / "updates"
metadata = desktop.publish_desktop("linux", bundle, archive, updates, log=lambda *_: None)
signed = []
signer = lambda data: signed.append(data) or b"signature document\n"
metadata = desktop.publish_desktop("linux", bundle, archive, updates, signer=signer, log=lambda *_: None)
target = updates / "linux-x64"
self.assertEqual(json.loads((target / "version.json").read_text()), metadata)
# The detached signature covers the exact published feed bytes.
self.assertEqual(signed, [(target / "version.json").read_bytes()])
self.assertEqual((target / "version.json.sig").read_bytes(), b"signature document\n")
self.assertEqual(metadata["architectures"], ["x64"])
self.assertEqual(metadata["sha256"], desktop.hashlib.sha256((target / metadata["file"]).read_bytes()).hexdigest())
metadata["versionCode"] += 1
(target / "version.json").write_text(json.dumps(metadata))
with self.assertRaisesRegex(ValueError, "older build"):
desktop.publish_desktop("linux", bundle, archive, updates)
desktop.publish_desktop("linux", bundle, archive, updates, signer=signer)
@patch.object(desktop.platform, "system", return_value="Darwin")
def test_macos_feed_uses_actual_architectures_and_native_build_stamp(self, _):
bundle, archive = self.build("macos", flutter="/fixture/flutter")
metadata = desktop.publish_desktop("macos", bundle, archive, self.root / "updates", log=lambda *_: None)
metadata = desktop.publish_desktop("macos", bundle, archive, self.root / "updates",
signer=lambda data: b"{}\n", log=lambda *_: None)
self.assertTrue((self.root / "updates/macos/version.json.sig").is_file())
self.assertEqual(metadata["architectures"], ["arm64", "x64"])
command = next(c for c in self.runner.calls if c[1:3] == ["build", "macos"])
self.assertIn(f"--dart-define=PIPELINES_NATIVE_BUILD_CODE={metadata['versionCode']}", command)
def test_desktop_builds_embed_the_trusted_update_keys(self):
self.build("linux", update_keys=("--dart-define=PIPELINES_UPDATE_PUBLIC_KEY=abc",))
run = next(c for c in self.runner.calls if c[:2] == ["docker", "run"])
self.assertIn("--dart-define=PIPELINES_UPDATE_PUBLIC_KEY=abc", run)
def test_desktop_server_prefill_rejects_embedded_credentials(self):
with self.assertRaisesRegex(ValueError, "embedded credentials"):
self.build("linux", server_url="wss://secret@example.com/connect")