Repository navigation
signing: sign for distribution with an existing identity - #326
TartanLeGrand wants to merge 4 commits into
Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
|
Related physical-device repro while investigating #131/#326:
Does #326's per-bundle signing work cover this |
|
Thanks for the detailed report. Short answer: I don't know whether #326 fixes this, and I have not tested a Safari web extension myself. What I can say:
"Missing bundle ID" while creating the placeholder makes me suspect installd fails to read the extension's bundle metadata rather than its signature, but that is a guess. What would narrow it down:
If you can share the |
|
Distribution signing rejects the associated domains grant of a real App Store profile. What happens
Xcode signs the same app for App Store distribution without complaint. ReproductionIdentifiers replaced with placeholders.
Cause
The tests do not catch it because Suggested fixThe two mixed cases case let (grant as [String], request as String):
return permits(grant: grant, request: [request])
case let (grant as String, request as [String]):
return permits(grant: [grant], request: request)Plus a test in |
|
Thanks @Jorgagu, confirmed and fixed in 9fed60e: |
Sign with an Apple Distribution identity loaded from a .p12 and App Store, Ad Hoc or Enterprise profiles the user already has, without talking to Apple. Each bundle gets the most specific matching profile, and its entitlements are derived from that profile and narrowed to what the bundle asks for, then passed to the signer per bundle through entitlementMapping. The .p12 is read with OpenSSL in CXKit: neither swift-crypto nor swift-certificates can parse PKCS#12.
xtool sign re-signs an existing .ipa or .app for distribution, and xtool dev build accepts the same --p12/--profile options. The .p12 password comes from an environment variable or a file, never from an argument.
9fed60e to
ff04d51
Compare
|
I rebased this on main now that #389 replaced zsign with RCodesign, and it got a lot smaller:
The two questions I had with zsign are answered by tests against RCodesign:
Both stay as regression tests. The history is now three commits on top of main. |
|
Tried this on a real app with extensions (a widget, a notification service extension, keychain sharing, push), signing each bundle with its own App Store profile: the per-bundle profile matching works, and the build was accepted and installs from TestFlight. One thing I had to change. The app's entitlements files say Smaller observation: the notification service extension has no entitlements file, so it falls back to everything its profile grants, which here means |
An app's entitlements file says aps-environment = development, as every debug build needs. Like Xcode's export, a distribution signature claims the profile's value (production) instead of refusing the build.
|
Thanks @gulian, agreed: matching Xcode's export is the right behaviour, and asking users to pass On the extension without an entitlements file: you're right that it currently falls back to everything its profile grants. I'll check what Xcode signs such an extension with for distribution before changing anything, since claiming less than the profile is safer only if App Store Connect and the OS agree. |
What does this PR do?
Adds signing for distribution (App Store, TestFlight, Ad Hoc, Enterprise) with an identity and
profiles the user already has. Nothing is created or revoked on Apple's side, so it works
offline and in CI.
DistributionIdentityloads an Apple Distribution certificate and key from a.p12.DistributionProfilereads App Store / Ad Hoc / Enterprise profiles (Mobileprovision.Digestnow exposes
kindandplatforms) and checks them against the identity.DistributionEntitlementsderives each bundle's entitlements from its profile, narrowed towhat the bundle asks for (like Xcode). Grants Apple issues as a string where the app asks for
an array (e.g. associated domains
*) are accepted.DistributionSignerpicks the most specific profile per bundle, embeds it, and signs throughthe
signerdependency with.real(certificate, privateKey)and a per-bundleentitlementMapping, the same pathAutoSigneruses.xtool sign <ipa|app>and--p12/--profile/--entitlementsonxtool dev build.The
.p12password comes fromXTOOL_P12_PASSWORD(or--p12-password-env) or--p12-password-file, never from an argument.The
.p12is parsed with OpenSSL in CXKit (already linked through xtool-core): swift-crypto andswift-certificates have no PKCS#12 support. Providers are loaded once, since loading them
concurrently with
PKCS12_parsebroke parsing in parallel tests.How was it tested?
swift teston Linux: 87 tests, all passing, including 30 for this feature.(
scripts/generate-signing-fixtures.sh); no real secret is involved.single SHA-256 CodeDirectory, and an executable with no room for
LC_CODE_SIGNATUREfails to sign and is left untouched.
AI tool usage
How much of this PR was AI-assisted? (check one)
Besides my review, the change was validated by running it (tests, real builds, device installs and App Store Connect uploads where stated above). I will answer review questions myself.