Skip to content

feat(macOS): make the Sparkle public key configurable - #11455

Merged
Rello merged 1 commit into
masterfrom
work/sparkle-public-key
Nov 30, 2026
Merged

Rello merged 1 commit into
masterfrom
work/sparkle-public-key

Conversation

@claucambra

Copy link
Copy Markdown
Contributor

Summary

Custom macOS distributions need to verify updates signed with their own release keys.

TODO

  • ...

Checklist

AI (if applicable)

Custom macOS distributions need to verify updates signed with their own release keys.

Assisted-by: Codex:gpt-6
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
@claucambra claucambra added this to the 35.1.0 milestone Nov 30, 2026
@claucambra claucambra self-assigned this Nov 30, 2026
@claucambra claucambra added the os: 🍎 macOS Apple macOS, formerly also known as OS X label Nov 30, 2026
@claucambra

Copy link
Copy Markdown
Contributor Author

/backport to stable-35.0

@claucambra claucambra changed the title feat(macos): make the Sparkle public key configurable feat(macOS): make the Sparkle public key configurable Nov 30, 2026
@claucambra

Copy link
Copy Markdown
Contributor Author

/backport to stable-34.0

@claucambra

Copy link
Copy Markdown
Contributor Author

/backport to stable-33.0

@Rello
Rello merged commit 9c1e775 into master Nov 30, 2026
21 of 23 checks passed
@Rello
Rello deleted the work/sparkle-public-key branch November 30, 2026 14:25
@i2h3

i2h3 commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

This PR was merged while I was reviewing it. Finding 1 still needs a follow-up PR.

Must change

  1. Branded builds get an empty update key and show an error at every start (NEXTCLOUD.cmake:23, cmake/modules/MacOSXBundleInfo.plist.in:55)
    • What this is: SUPublicEDKey in Info.plist is the public key that Sparkle (the macOS update framework) uses to check that an update really comes from us. This PR fills it from the new CMake variable APPLICATION_SPARKLE_PUBLIC_ED_KEY.
    • Problem: The variable is only set in NEXTCLOUD.cmake. Branded builds bring their own copy of that file. This is why CMakeLists.txt already has fallbacks for other branding variables, like APPLICATION_VIRTUALFILE_SUFFIX and APPLICATION_SIGNUP_URL. A branded NEXTCLOUD.cmake without the new line gives <string></string> in Info.plist. I checked this with configure_file on the template. Sparkle decodes the empty string to 0 bytes instead of 32, marks the key invalid, and refuses to start. SPUStandardUpdaterController then shows a modal "Unable to Check For Updates" alert one second after every start, when the app is in /Applications. Today the same build gets our key and shows no alert.
    • Fix: Move the line from NEXTCLOUD.cmake to CMakeLists.txt, next to APPLICATION_SIGNUP_URL, and wrap it in if(NOT DEFINED APPLICATION_SPARKLE_PUBLIC_ED_KEY) ... endif(). A branded NEXTCLOUD.cmake and -DAPPLICATION_SPARKLE_PUBLIC_ED_KEY=... both still win. I tested all three cases with a small CMake project.
    • If skipped: Every custom build that pulls this change without editing its NEXTCLOUD.cmake ships an app that shows this alert at each start and never checks for updates.

Should change

  1. The new test passes when the key is empty (test/macOS/checksparklepublickey.cmake:9)
    • What this is: The test reads SUPublicEDKey from the built app with plutil and compares it with the CMake variable.
    • Problem: Both values come from the same variable, so they only differ if CMake's own text replacement breaks. With the empty key from finding 1, both sides are "" and plutil exits with 0, so the test passes. I ran the script on such a plist and it passed. In CI the key is the default, which is the same value that master has in the template. So the test also stays green if someone puts the fixed key back into the template.
    • Fix: Also check the shape of the key. An Ed25519 public key (the key type Sparkle uses) is 32 bytes, which is 44 Base64 characters ending in =. CMake regular expressions have no {n} counts, so check the length on its own:
      string(LENGTH "${public_key}" public_key_length)
      if(NOT result STREQUAL "0" OR NOT public_key STREQUAL EXPECTED_PUBLIC_KEY
         OR NOT public_key_length EQUAL 44 OR NOT public_key MATCHES "^[A-Za-z0-9+/]+=$")
      I ran this check: it accepts the default key and rejects an empty key, a short key, a key without = and a key with other characters. It still does not catch a fixed key in the template. Nothing short of a second configure with another key would.
    • If skipped: The test stays green for the one broken build this change can produce, so it gives no protection.

Nice to have

  1. TARGET nextcloud in the test condition is always true (test/macOS/CMakeLists.txt:17)
    • What this is: The new test only gets registered if the nextcloud target exists and a bundle is built.
    • Problem: test/ is only added after src/, and src/gui always creates nextcloud. Without src/gui (BUILD_LIBRARIES_ONLY), every other test in this file fails to link to nextcloudCore anyway. So this part of the check never changes the result.
    • Fix: if(BUILD_OWNCLOUD_OSX_BUNDLE).
    • If skipped: One more condition that readers must think about. Nothing breaks.

Assisted by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

os: 🍎 macOS Apple macOS, formerly also known as OS X

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants