Skip to content

ci: sign darwin binaries with an Apple signing key in Google Cloud KMS - #32211

Merged
sreya merged 2 commits into
mainfrom
apple-kms
Nov 16, 2026
Merged

sreya merged 2 commits into
mainfrom
apple-kms

Conversation

@sreya

@sreya sreya commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

Darwin binaries are signed with an Apple Developer ID certificate whose private key currently lives in GitHub secrets as an exportable PKCS#12 bundle. This moves signing to a non-exportable HSM key in the coder-release-signing project introduced by coder/gcp#331 (key + IAM in coder/gcp#333). rcodesign reaches the key through the Cloud KMS PKCS#11 library (libkmsp11), authenticating as release-signer@coder-release-signing through the environment-gated github-release-signing workload identity pool.

  • scripts/sign_darwin.sh gains a Cloud KMS PKCS#11 mode, selected by AC_PKCS11_LIBRARY. The PKCS#12 path remains as a fallback, so rollback is restoring the previous environment variables.
  • A new install-rcodesign composite action builds rcodesign from a pinned upstream revision with the pkcs11 cargo feature, because PKCS#11 support is not in any apple-codesign release (latest is 0.29.0) and the feature is off by default. It also applies the apple-codesign/src portion of apple-codesign: initialize PKCS#11 modules once per process indygreg/apple-platform-rs#350; without it the PKCS#11 module is initialized twice per process and signing fails with CKR_CRYPTOKI_ALREADY_INITIALIZED. The binary is cached by revision and patch hash.
  • Darwin signing reuses the release-signer auth step that the KMS GPG signing (chore: add optional Cloud KMS dual signing for release GPG signatures #32209) added (gcloud_auth_gpg): its credentials file is pinned to GOOGLE_APPLICATION_CREDENTIALS on the build step only, where the PKCS#11 library reads it, while jsign (Windows) and gsutil keep the ambient coder-ci credentials. The step loses its GPG enablement gate and GPG-only naming because darwin signing needs the credentials even when optional KMS GPG signing is disabled; the GPG steps keep their own gates.
  • Secrets AC_CERTIFICATE_P12_BASE64/AC_CERTIFICATE_PASSWORD are replaced by AC_CERTIFICATE_PEM (the public certificate), AC_KMS_KEY_RING, and AC_KMS_KEY, plus the GPG_KMS_WORKLOAD_ID_PROVIDER/GPG_KMS_SERVICE_ACCOUNT secrets already used by chore: add optional Cloud KMS dual signing for release GPG signatures #32209 (one identity, one auth step, one configuration pair). Notarization (App Store Connect API key) is unchanged.

The key is already imported into the HSM and its public key verified against the certificate, and the PKCS#11 signing path was exercised end to end against SoftHSM with a Mach-O binary. Validated end to end on 2026-11-16 via a temporary dispatch-only test workflow: the full release signing path (environment gate, WIF exchange, release-signer, libkmsp11, HSM AsymmetricSign) produced darwin zips signed by certificate serial 161CE6614DEBB3FA0F8DE71963662954 and Apple accepted both notarization submissions. The temporary test clause and branch have been removed.

Not mergeable until resolved elsewhere: ev-code-signing/signev are still disabled in coder-ci (Windows signing in the same jobs fails until security re-enables or replaces them), and dry-run releases cannot exchange a signing token under the release WIF condition (workflow_dispatch on v* tags only).

Refs coder/gcp#331, coder/gcp#333, coder/gcp#335, indygreg/apple-platform-rs#350

@sreya
sreya temporarily deployed to main November 15, 2026 23:59 — with GitHub Actions Inactive
@sreya
sreya temporarily deployed to main November 16, 2026 00:16 — with GitHub Actions Inactive
@sreya
sreya temporarily deployed to main November 16, 2026 00:16 — with GitHub Actions Inactive
@sreya
sreya marked this pull request as ready for review November 16, 2026 00:24
@sreya
sreya temporarily deployed to main November 16, 2026 00:24 — with GitHub Actions Inactive
@sreya
sreya temporarily deployed to main November 16, 2026 01:30 — with GitHub Actions Inactive
@sreya
sreya requested a review from a team November 16, 2026 01:52
@sreya
sreya temporarily deployed to main November 16, 2026 01:52 — with GitHub Actions Inactive
@sreya
sreya temporarily deployed to main November 16, 2026 01:52 — with GitHub Actions Inactive
The Apple Developer ID Application certificate's private key moves from a
PKCS#12 file in GitHub secrets into Google Cloud KMS (HSM protection level),
matching how Windows EV signing already works. rcodesign reaches the key
through the Cloud KMS PKCS#11 library (libkmsp11), authenticated with the
existing code-signing workload identity federation service account.

Because PKCS#11 support is unreleased upstream and gated behind an optional
cargo feature, rcodesign is now built from a pinned revision with a vendored
copy of the upstream fix for double module initialization
(indygreg/apple-platform-rs#350), cached by revision
and patch hash.

sign_darwin.sh keeps the PKCS#12 path as a fallback so the migration can be
rolled back by restoring the previous environment variables.
Darwin signing authenticates as release-signer@coder-release-signing through
the auth step the KMS GPG signing added (gcloud_auth_gpg): its credentials
file is pinned to GOOGLE_APPLICATION_CREDENTIALS on the build step, where the
Cloud KMS PKCS11 library reads it, while jsign and gsutil keep the ambient
coder-ci credentials. The step loses its GPG enablement gate and its GPG-only
naming because darwin signing needs the credentials even when the optional
KMS GPG signing is disabled; the GPG steps keep their own gates.
@sreya
sreya temporarily deployed to main November 16, 2026 02:08 — with GitHub Actions Inactive
@sreya
sreya temporarily deployed to main November 16, 2026 02:09 — with GitHub Actions Inactive
@sreya
sreya merged commit a8ed5a1 into main Nov 16, 2026
33 of 34 checks passed
@sreya
sreya deleted the apple-kms branch November 16, 2026 02:19
@sreya
sreya temporarily deployed to main November 16, 2026 02:19 — with GitHub Actions Inactive
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 16, 2026

This branch had an error being deployed

1 failed and 1 inactive deployments
main — 7ec9ac95 Deployed Nov 16, 2026 by sreya via cla #257213
docs-preview — 7ec9ac95 Deployed Nov 16, 2026 by sreya via cleanup #80
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants