Skip to content

fix(ios): decode provisioning profiles without touching the keychain - #1036

Merged
janicduplessis merged 3 commits into
mainfrom
fix/profile-decode-keychain
Sep 24, 2026
Merged

janicduplessis merged 3 commits into
mainfrom
fix/profile-decode-keychain

Conversation

@janicduplessis

@janicduplessis janicduplessis commented Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator

Description

readEmbeddedProfile decoded embedded.mobileprovision with security cms -D, which imports every certificate embedded in the CMS message into the login keychain. That runs on every ios --device install, so real installs add the profile's developer certs to the user's keychain.

The compat test made it pile up: each run adds 3 fixed-name fixture certs (Jane Fixture (TEAMID5678)). One dev Mac had 1526 of them, with trustd --agent near 100% CPU.

Solution

Decode with /usr/bin/openssl smime -verify -noverify -inform DER instead. It ships with every macOS and doesn't touch the keychain; the absolute path keeps a Homebrew, conda or nix openssl on PATH from turning a broken install into a misleading "corrupt profile" refusal. security cms has no way to skip the import (-k with a missing keychain just fails). -noverify skips chain trust, which the gate never relied on since it only reads the plist.

The STIM_NO_PROFILE reason and guide entry now name openssl smime.

Test plan

  • On a real Xcode-installed profile, security cms -D, /usr/bin/openssl (LibreSSL 3.3.6) and Homebrew OpenSSL 3.6.3 produce byte-identical plists.
  • The readEmbeddedProfile compat test now asserts the signer's SHA-1 is absent from security find-certificate -a -Z after decoding.
  • engine-ios-signing.compat.test.ts: 13/13 pass; the fixture cert count stayed at 1526 (it grew by 3 per run before).

Fixes #1035

security cms -D imports the certificates embedded in a profile into the login keychain. openssl smime decodes the same plist without that side effect. Fixes #1035.
@janicduplessis
janicduplessis marked this pull request as ready for review September 24, 2026 18:25
@janicduplessis
janicduplessis merged commit 39e4905 into main Sep 24, 2026
8 checks passed
@janicduplessis
janicduplessis deleted the fix/profile-decode-keychain branch September 24, 2026 18:34
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.

Reading embedded.mobileprovision imports its certificates into the login keychain

1 participant