From 42d6424e9fa00283f27af90463609fee35c01966 Mon Sep 17 00:00:00 2001 From: "mula.liu" Date: Mon, 26 Oct 2026 09:44:53 +0800 Subject: [PATCH] build: sign macOS ad-hoc so other machines can open the app MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The published DMG was refused on a fresh Mac as damaged/malware, with only "Move to Trash" — no 仍要打开, no pane entry to approve. That is not the "unidentified developer" box, and it is worse than shipping unsigned. Cause: `signingIdentity: "Shift Local Signing"`, a locally created self-signed certificate. On the build host it looks healthy — `codesign` reports valid on disk and satisfies its Designated Requirement, `spctl` even accepts it — but the certificate lives only in this keychain, is self-issued and CA:FALSE, so it cannot chain to a trusted root on any other machine. Sequoia turns an unchainable signature on a quarantined download into a hard refusal. Releases that opened fine predates that config entry and were ad-hoc signed, which gets the softer prompt the user can clear (right-click → 打开, or 允许 in 隐私与安全性). Set signingIdentity to "-" explicitly so this cannot drift back, and rebuild all three macOS/Windows artifacts from it: app is `Signature=adhoc`, the DMG carries no signature of its own, and the pkg payload is ad-hoc too. Docs corrected: the earlier explanation in "macOS packaging" blamed the DMG container, which was wrong — the container still matters for first install (an installed app is not left quarantined, so a .pkg opens with no prompt), but the malware verdict came from the certificate. --- README.md | 2 +- README.zh-CN.md | 2 +- docs/RELEASE.md | 65 ++++++++++++++++++++------------------- docs/ROADMAP.md | 17 +++++----- src-tauri/src/update.rs | 4 +-- src-tauri/tauri.conf.json | 2 +- 6 files changed, 48 insertions(+), 44 deletions(-) diff --git a/README.md b/README.md index e9c3f81..48a57be 100644 --- a/README.md +++ b/README.md @@ -292,7 +292,7 @@ Each is overridable in Settings. File actions offer a *collect everything in one ## Updates -A new macOS machine should install **`Shift-macOS-universal.pkg`**: builds are signed with a self-signed identity and not notarized, so Gatekeeper calls Shift an unidentified developer, and an installed package leaves the app free of the quarantine flag. If you install the disk image instead, the first launch needs one approval in System Settings → Privacy & Security. Details in `docs/RELEASE.md`. +A new macOS machine should install **`Shift-macOS-universal.pkg`**: builds are ad-hoc signed and not notarized, so Gatekeeper calls Shift an unidentified developer, and an installed package leaves the app free of the quarantine flag - it opens with no prompt. From the disk image, the first launch needs one approval (right-click → Open, or 允许 in System Settings → Privacy & Security). Details in `docs/RELEASE.md`. The update channel is this repository: a `releases` branch holding the installers plus `shift-update.json`, which names each artifact, its size and its SHA256. The feed URL is derived from the git remote at build time - Gitea, GitHub and GitLab forms are known, and `SHIFT_UPDATE_URL` overrides it - so no update service has to be deployed anywhere. diff --git a/README.zh-CN.md b/README.zh-CN.md index 81acc57..78c252b 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -294,7 +294,7 @@ Shift 会持续维护局域网内其他 Shift 实例的列表,并据此提供 ## 软件更新 -新的 macOS 机器请安装 **`Shift-macOS-universal.pkg`**:本项目的构建使用自签名身份且未做公证,Gatekeeper 会把 Shift 判为身份不明的开发者,而通过安装包安装不会把隔离属性带给应用。若改用磁盘镜像安装,首次打开需要在「系统设置 → 隐私与安全性」里允许一次。详见 `docs/RELEASE.md`。 +新的 macOS 机器请安装 **`Shift-macOS-universal.pkg`**:本项目的构建采用 ad-hoc 签名且未做公证,Gatekeeper 会把 Shift 判为身份不明的开发者,而通过安装包安装不会把隔离属性带给应用,装好后打开不会再有提示。若改用磁盘镜像安装,首次打开需要允许一次(右键 → 打开,或在「系统设置 → 隐私与安全性」中点「允许」)。详见 `docs/RELEASE.md`。 更新通道就是这个仓库:一条 `releases` 分支保存安装包以及 `shift-update.json` 清单,清单写明每个安装包的名称、体积与 SHA256。更新源地址在构建时由 git 远端推导——已适配 Gitea、GitHub、GitLab 三种形式,也可用 `SHIFT_UPDATE_URL` 覆盖——因此无需额外部署任何更新服务。 diff --git a/docs/RELEASE.md b/docs/RELEASE.md index b781641..660dd3a 100644 --- a/docs/RELEASE.md +++ b/docs/RELEASE.md @@ -70,44 +70,45 @@ never accumulates gigabytes of installer history while `main` stays clean. ## macOS packaging -Shift builds are signed with a **self-signed** identity ("Shift Local Signing") and are -**not notarized** — notarization needs an Apple Developer ID account. Gatekeeper therefore -calls any Shift build an unidentified developer, and how annoying that is depends entirely -on the container: +Shift builds are **ad-hoc signed** (`signingIdentity: "-"` in `tauri.conf.json`) and are +**not notarized** — notarization needs an Apple Developer ID account, which this project +does not have. Gatekeeper therefore cannot vouch for any Shift build, and what a fresh +machine says depends on how the binary is signed: -| Container | What a fresh machine does | +| Signing | What a fresh machine says | | --- | --- | -| DMG, app dragged into /Applications | The app itself carries the quarantine flag from the browser, so **the first launch of Shift** is refused: *"无法打开,因为来自身份不明的开发者"*. The user approves in 系统设置 → 隐私与安全性 (允许 / 仍要打开), or right-clicks the app and chooses 打开. | -| `.pkg`, installed with Installer.app or `installer` | The approval moves to the package, once, before anything is installed (double-click reports it, right-click → 打开 passes it, `installer` from a terminal needs nothing). `installer` does not propagate quarantine onto what it installs, so **the installed app launches with no prompt at all** — verified: an installed copy carries only `com.apple.provenance`, no `com.apple.quarantine`. | +| Ad-hoc (`Signature=adhoc`) — **current** | "cannot be opened because it is from an unidentified developer", and the box offers a way through: Cancel, then right-click → 打开, or 允许 in 系统设置 → 隐私与安全性 | +| Self-signed certificate | "cannot be opened because it is damaged" / reported as malware, with **only 移至废纸篓** — no override, no pane entry to approve | +| Developer ID + notarized | Opens on double-click, no prompt | -Both containers hold the same signed universal bundle — `pkgbuild` neither re-signs nor -strips the signature, and the payload passes `codesign --verify --deep --strict`. +The middle row is the trap that cost a release. Signing with a locally created +certificate ("Shift Local Signing") *looks* better — `codesign` on the build machine reports +`valid on disk` and `satisfies its Designated Requirement`, and `spctl` even accepts it — but +the certificate lives only in that one Mac's keychain, is self-issued, and is `CA:FALSE`, so +on any other machine it cannot chain to a trusted root. Sequoia turns an unchainable +signature on a quarantined download into a hard refusal, which is strictly worse than no +certificate at all. If the identity is used again it must be installed **and trusted** on +every machine, which is not something to ask of a user. -So the channel publishes both, for different jobs: +So: ad-hoc, and the two containers each cover one job. -- **`Shift-macOS-universal.pkg`** — first install on any machine. Build it with - `scripts/macos-pkg.sh `; it stages the bundle under a - `/Applications` root and runs `pkgbuild`, keeping the app's own signature. - The package itself is unsigned: `productsign` needs a certificate with the *Installer - Signing* purpose and this build has only a code-signing identity. A browser-downloaded - unsigned package is refused on a plain double-click, so the user approves it once — - right-click → 打开, or 仍要打开 in 系统设置 → 隐私与安全性. What the package changes is - *where* that single approval lands: on the download, before install, instead of on the - app every time it is opened. - `installer -pkg Shift-macOS-universal.pkg -target /` from a terminal needs no such - permission at all. -- **`Shift-macOS-universal.dmg`** — the `macos` manifest key, because - `update_install`'s handoff mounts the image with `hdiutil` and copies the bundle out of - it. Pointing the key at a `.pkg` would make that mount fail, so the key stays a DMG - until the updater learns to run `installer`. A DMG Shift downloads itself arrives without - a quarantine flag (`curl` sets none, and the handoff strips it anyway), which is why - in-app updates never trigger the prompt — it is only the browser download on a new - machine that does. +| Container | First launch on a fresh machine | +| --- | --- | +| `.pkg`, via Installer.app or `installer` | `installer` does not propagate quarantine onto what it installs, so the app opens with **no prompt at all**. Verified: an installed copy carries `com.apple.provenance` and no `com.apple.quarantine`. The package itself is unsigned (`productsign` needs an *Installer Signing* certificate; a code-signing identity is rejected), so a browser-downloaded package may need right-click → 打开 once, before anything installs. `installer -pkg … -target /` needs nothing. | +| `.dmg`, app dragged to /Applications | The app keeps the browser's quarantine flag, so the first launch needs the one approval above. Shift's own downloader sets no quarantine flag, which is why **in-app updates never prompt** — only a browser download on a new machine does. | -Closing this for good means an Apple Developer ID: sign with `Developer ID Application`, -notarize with `notarytool`, and staple the ticket. Then both containers open on double-click -with no pane to visit, and Screen Recording approval stops resetting between builds because -the identity stops changing. +`scripts/macos-pkg.sh ` builds the package: it stages the bundle under +an `/Applications` root and runs `pkgbuild`, which neither re-signs nor strips the payload — +the CDHash is identical in the built bundle, the DMG copy and the pkg copy. + +The `macos` manifest key stays a DMG on purpose: `update_install`'s handoff mounts the image +with `hdiutil` and copies the bundle out of it, so pointing the key at a `.pkg` would make +every in-app update fail to mount. + +Closing this for good means an Apple Developer ID: `Developer ID Application` + +`notarytool` + `stapler staple`. Then both containers open on double-click with no pane to +visit, and Screen Recording approval stops resetting between builds because the identity +stops changing. ## Publishing diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index a7a226f..6a24750 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -104,13 +104,16 @@ names what is still missing. launch after an upgrade, re-deriving each entry's kind from the file rather than trusting the older store's guess, then the legacy key is dropped so a later upgrade cannot resurrect rows the user has since removed. -- Signed and notarized macOS package: pending (builds are signed with a local identity). - Until then the channel also publishes `Shift-macOS-universal.pkg`, because Gatekeeper - refuses an unnotarized app on first launch and `installer` does not leave the installed - copy quarantined — so the prompt moves to the download, once, instead of the app. The - `macos` manifest key stays a DMG so the in-app handoff can keep mounting it; see - "macOS packaging" in `docs/RELEASE.md`. Notarization needs a Developer ID account, and - it would also stop Screen Recording approval from resetting between builds. +- Signed and notarized macOS package: pending. Builds are **ad-hoc** signed, deliberately: + signing with a locally created certificate made every other machine refuse the app as + *damaged / malware* with no override, because that certificate cannot chain to a trusted + root anywhere else, while an ad-hoc binary gets the softer "unidentified developer" box + the user can approve. The channel also publishes `Shift-macOS-universal.pkg`, since + `installer` does not leave the installed copy quarantined and the app then opens with no + prompt at all. The `macos` manifest key stays a DMG so the in-app handoff can keep + mounting it; see "macOS packaging" in `docs/RELEASE.md`. A Developer ID plus notarization + removes the prompt entirely and would also stop Screen Recording approval from resetting + between builds. - Signed Windows installer: pending. - Manifest signing is done. `scripts/release-key.py` mints the release key, `publish-release.sh --key` publishes a detached `shift-update.sig` over the manifest's diff --git a/src-tauri/src/update.rs b/src-tauri/src/update.rs index f6153e5..41469ba 100644 --- a/src-tauri/src/update.rs +++ b/src-tauri/src/update.rs @@ -753,8 +753,8 @@ if ! /usr/bin/ditto "$mount/Shift.app" "$bundle.new" >>"$log" 2>&1; then status=1 else # A DMG fetched by a browser carries a quarantine flag, and an app copied out of - # one is re-assessed on next launch. This build is signed but not notarized, so - # drop the flag the same way a manual drag out of the image would. + # one is re-assessed on next launch. This build is ad-hoc signed and not notarized, + # so drop the flag the same way a manual drag out of the image would. /usr/bin/xattr -dr com.apple.quarantine "$bundle.new" 2>/dev/null if mv "$bundle" "$bundle.old" >>"$log" 2>&1 && mv "$bundle.new" "$bundle" >>"$log" 2>&1; then /bin/rm -rf "$bundle.old" diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index cdaef45..4944969 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -130,7 +130,7 @@ "macOS": { "minimumSystemVersion": "13.0", "infoPlist": "Info.plist", - "signingIdentity": "Shift Local Signing", + "signingIdentity": "-", "hardenedRuntime": false } }