To rotate an expired Apple Distribution certificate on a rented Mac, generate a key and CSR with openssl, upload the CSR to Apple, import the issued .cer with security import, and confirm the result with security find-identity -v -p codesigning. You do not need Keychain Access.app. The signing keys and certificates are yours: keep them in the Mac's own keychain and in your own secret manager, and nowhere else.
Apple's overview of the signing flow is Preparing your app for distribution. The authoritative notes on Developer ID expiry behavior are on the Developer ID support page.
What does a valid signing identity consist of?
A valid identity is three parts that must all be present, with the certificate linked to its private key:
- Apple Root CA. Pre-installed in the System keychain; you do not touch it.
- Apple Worldwide Developer Relations (WWDR) Intermediate. Also in the System keychain. Xcode ships updated intermediates; download replacements from Apple's certificate authority list if a build host is missing the current one.
- Your Development or Distribution certificate. Issued by Apple after you submit a CSR, and stored in the login keychain alongside its private key.
If the intermediate is absent or the private key is on a different machine, xcodebuild -allowProvisioningUpdates fails with a signing error. Apple is rolling out G2 Developer ID authorities, so check the state of your own certificates in the Apple Developer account portal rather than trusting a third-party deadline write-up.
How do I generate the CSR on the remote Mac?
Create the key and the CSR in a terminal on the Mac that will sign builds. Do not create the key locally and copy it across a network.
#!/usr/bin/env bash
set -euo pipefail
umask 077
CERT_NAME="acme_distribution_$(date -u +%Y%m%dT%H%M%SZ)"
CSR_FILE="${CERT_NAME}.certSigningRequest"
KEY_FILE="${CERT_NAME}.key"
EMAIL="releases@example.com"
COUNTRY="US"
# 2048-bit RSA key (minimum Apple accepts for code-signing CSRs)
openssl genrsa -out "$KEY_FILE" 2048
openssl req -new \
-key "$KEY_FILE" \
-out "$CSR_FILE" \
-subj "/emailAddress=${EMAIL}/CN=${CERT_NAME}/C=${COUNTRY}"
echo "Upload ${CSR_FILE} at developer.apple.com → Certificates, Identifiers & Profiles."
echo "Keep ${KEY_FILE} on this Mac; it is required to use the issued certificate."
Upload $CSR_FILE and pick Apple Distribution for App Store and TestFlight signing, or Developer ID Application for direct distribution and notarization.
How do I import the signed certificate?
Download the .cer from the developer portal, transfer it to the remote Mac, and import it into the same login keychain that holds the private key.
#!/usr/bin/env bash
set -euo pipefail
CER_FILE="${1:?pass the downloaded .cer path}"
KEY_FILE="${2:?pass the matching .key path from the CSR step}"
KEYCHAIN="$HOME/Library/Keychains/login.keychain-db"
# Make sure the login keychain is unlocked for this shell
security unlock-keychain "$KEYCHAIN"
# Import the issued certificate; -T grants codesign access without a GUI prompt
security import "$CER_FILE" \
-k "$KEYCHAIN" \
-T /usr/bin/codesign \
-T /usr/bin/productbuild
# Import the matching private key (same keychain so the identity is complete)
security import "$KEY_FILE" \
-k "$KEYCHAIN" \
-T /usr/bin/codesign
security find-identity -v -p codesigning "$KEYCHAIN"
The -T /usr/bin/codesign flag lets codesign use the key non-interactively; without it, a CI job can hang at a GUI password prompt. Pass the real file paths as arguments rather than globbing the key filename, so a stray .key file from a past rotation cannot be imported by accident.
How do I verify the identity chain?
Run security find-identity -v -p codesigning. A healthy result:
1) A1B2C3D4E5F6... "Apple Distribution: Example Corp (TEAM123ABC)"
1 valid identities found
If it reports 0 valid identities found, one of these is missing:
- WWDR intermediate. Download the current intermediate from Apple's CA list and add it:
sudo security add-trusted-cert -d -k /Library/Keychains/System.keychain <intermediate>.cer. - Private key. Re-run
security importfor the.keyfile; the login keychain only forms an identity when key and certificate are both present. - Certificate. Re-import the
.cerfrom the developer portal.
Confirm expiry and issuer with:
security find-certificate -a -c "Apple Distribution" -p \
| openssl x509 -noout -subject -issuer -dates
How do I export an encrypted .p12 backup?
Use security export -t identities -f pkcs12 and store the result in your own secret manager, never in source control. A .p12 bundles the certificate and its private key in a password-protected container, so it can also seed another signing host that you control.
#!/usr/bin/env bash
set -euo pipefail
umask 077
P12_FILE="distribution_$(date -u +%Y%m%d).p12"
KEYCHAIN="$HOME/Library/Keychains/login.keychain-db"
# Omit -P so security prompts interactively; the passphrase never hits shell history
security export \
-k "$KEYCHAIN" \
-t identities \
-f pkcs12 \
-o "$P12_FILE"
echo "Encrypted p12 written to ${P12_FILE}"
Hand the passphrase to recipients out-of-band (a secret manager, not email). On the receiving Mac, run security import backup.p12 -k ~/Library/Keychains/login.keychain-db -P '<passphrase>' inside that user's shell. Provisioning profiles are separate files. Place them in ~/Library/MobileDevice/Provisioning Profiles/; they do not belong in a keychain.
When do certificates expire?
Typical validity is about a year for Development and Distribution certificates and about five years for Developer ID certificates.
| Certificate | Typical validity | What expiry breaks |
|---|---|---|
| Apple Development | ~1 year | Debug builds on test devices |
| Apple Distribution | ~1 year | New App Store / TestFlight archives |
| Developer ID Application | ~5 years | Signing new Mac app updates (already-signed binaries keep running per Gatekeeper) |
| Developer ID Installer | ~5 years | Signing new installer packages |
| WWDR Intermediate | Set by Apple | Any identity relying on the missing intermediate |
Confirm each exact expiry on the Developer portal before you plan a rotation; Apple reissues intermediates and has shifted some Developer ID chains to G2 authorities. Set a calendar reminder about 30 days before any Distribution certificate expires, because Xcode does not warn you before the first failing build.
Do certificate tasks need more than the Intel Mac VM?
Any plan fits, because generating a CSR, importing a certificate and exporting a .p12 need only a terminal. The Intel Mac VM ($25 a month, $2 a day) runs macOS Sequoia with Xcode 26.3 or earlier, which is enough for this runbook. Choose the Apple Silicon Mac VM ($39 a month) if the same host must also build with Xcode 26.4 or later. Keep your keys in your own keychain and secret manager. Figment does not back up your Mac.
Related guides: