Skip to content

fix(desktop): fall back to old keychain when DPK unavailable (unsigned builds)#1266

Merged
wpfleger96 merged 1 commit into
mainfrom
duncan/keychain-dpk-fallback
Jun 25, 2026
Merged

fix(desktop): fall back to old keychain when DPK unavailable (unsigned builds)#1266
wpfleger96 merged 1 commit into
mainfrom
duncan/keychain-dpk-fallback

Conversation

@wpfleger96

Copy link
Copy Markdown
Collaborator

Problem

Unsigned and dev builds (tauri dev, hermit/cargo run) lack the hardened-runtime entitlement required by kSecUseDataProtectionKeychain. macOS returns errSecMissingEntitlement (-34018), which propagated up through store()load_or_create_identity → setup hook → panic.

This was introduced in #1264, which switched the macOS keychain backend to Data Protection Keychain. Release builds (properly signed with hardened runtime) work correctly. Dev builds do not.

Fix

Add is_dpk_unavailable(e: &SFError) -> bool that checks e.code() == -34018. All four macOS SecretStore methods (probe, load, store, delete) now have a fallback arm: when DPK returns -34018, they transparently retry via the legacy keyring crate path — the same path used on Windows and Linux.

Behavior after this fix

Build type Behavior
Signed release build DPK path — zero prompts after first device unlock
Unsigned dev build (tauri dev / hermit) Legacy keyring path — prompts once per key per session, no panic
Windows / Linux Unchanged

Files changed

  • desktop/src-tauri/src/secret_store.rs only

…d builds)

Unsigned/dev builds (tauri dev, hermit/cargo run) lack the hardened-runtime
entitlement required by kSecUseDataProtectionKeychain. macOS returns
errSecMissingEntitlement (-34018) and the app panics in the setup hook.

Treat -34018 as "DPK unavailable" across all four SecretStore methods
(probe/load/store/delete): when DPK returns that error, transparently retry
via the legacy keyring crate path. Release builds (properly signed) continue
using DPK with zero prompts. Dev builds fall back to old-keychain behavior
(prompts once per key per session) without panicking. Windows/Linux paths
are unchanged.

Co-authored-by: Will Pfleger <pfleger.will@gmail.com>
Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
@wpfleger96 wpfleger96 merged commit 958ac7a into main Jun 25, 2026
26 checks passed
@wpfleger96 wpfleger96 deleted the duncan/keychain-dpk-fallback branch June 25, 2026 02:53
wpfleger96 added a commit that referenced this pull request Jun 25, 2026
Buzz stored each secret as a separate keychain item — the identity key
plus one entry per managed agent (6 agents = 7 items total). On dev
builds (old keychain, null ACL) every read and write triggers a prompt:
15-20+ on first launch. On release builds (DPK) the first launch prompts
once per key (7 total). Goose solved this identically: one entry, all
secrets as a JSON map, one prompt total.

Switch SecretStore to the same pattern. A single blob entry (service
= the store's service name, username = "secrets") holds all keys as a
JSON map. The map is cached in-memory after the first read, so subsequent
probe/load/store/delete calls within the same process never touch the
keychain again. One prompt on first launch, zero after.

Migration: on first launch after upgrade the blob doesn't exist yet.
load() falls back to reading the old per-key DPK entry (macOS) or
legacy keyring entry (all platforms), writes it into the new blob, and
deletes the old item — one-time per key, transparent to callers.

The is_dpk_unavailable (-34018) fallback from #1266 is incorporated
here: unsigned dev builds fall back to the legacy keyring crate for the
single blob entry. The probe/load/store/delete semantics seen by callers
(IdentityKeyStore, KeyStore) are unchanged.

Co-authored-by: Will Pfleger <pfleger.will@gmail.com>
Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
wpfleger96 added a commit that referenced this pull request Jun 25, 2026
Buzz stored each secret as a separate keychain item — the identity key
plus one entry per managed agent (6 agents = 7 items total). On dev
builds (old keychain, null ACL) every read and write triggers a prompt:
15-20+ on first launch. On release builds (DPK) the first launch prompts
once per key (7 total). Goose solved this identically: one entry, all
secrets as a JSON map, one prompt total.

Switch SecretStore to the same pattern. A single blob entry (service
= the store's service name, username = "secrets") holds all keys as a
JSON map. The map is cached in-memory after the first read, so subsequent
probe/load/store/delete calls within the same process never touch the
keychain again. One prompt on first launch, zero after.

Migration: on first launch after upgrade the blob doesn't exist yet.
load() falls back to reading the old per-key DPK entry (macOS) or
legacy keyring entry (all platforms), writes it into the new blob, and
deletes the old item — one-time per key, transparent to callers.

The is_dpk_unavailable (-34018) fallback from #1266 is incorporated
here: unsigned dev builds fall back to the legacy keyring crate for the
single blob entry. The probe/load/store/delete semantics seen by callers
(IdentityKeyStore, KeyStore) are unchanged.

Co-authored-by: Will Pfleger <pfleger.will@gmail.com>
Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant