Keys & cryptography

Private key

The secret half of a key pair. Whoever holds the private key for a code signing certificate can sign builds as that developer. Lose it and you cannot rotate; leak it and someone else can sign as you.

Signing private keyCode signing private key

Apple code signing uses an asymmetric key pair: a public key inside a certificate that Apple has signed, and a private key that only you have. The private key is what actually signs a build. The certificate just lets a verifier (Xcode, codesign, the App Store, Gatekeeper) check that the signature came from the holder of the matching private key.

Where private keys live

  • On the Mac of whichever developer generated the original CSR. The key was created locally and never left that machine.
  • Exported into a .p12 file (PKCS#12) so a teammate or build server can import it.
  • Stored in a secret manager (1Password, AWS Secrets Manager, HashiCorp Vault) and pulled into CI at build time.
  • Held by a managed signing service like HexSign or fastlane match, encrypted at rest and decrypted only inside the signing process.

Common failure modes

  • The certificate is imported on a second Mac as a bare .cer, which never carries the key. Xcode then reports Missing private key for signing certificate and refuses to sign, because a certificate without its key can verify signatures but never create one.
  • The developer who generated the CSR leaves the company and nobody else has the private key. The certificate still works, but you cannot rotate it.
  • A .p12 with a weak password ends up in a public git repo. Anyone who finds it can sign builds as your team.
  • Two developers each generate their own private key for the same certificate type, so the team ends up with two distribution certificates and neither one matches the other's provisioning profile.

FAQ

Common questions about Private key

How do I tell whether a private key is still being used?

Match the key back to a certificate, then check that certificate's status. Run security find-identity -v -p codesigning to list every key and certificate pair your keychain can sign with, and compare the names against the certificates listed as active in the Apple Developer portal. A key whose certificate is expired or revoked signs nothing. A key paired with a valid, non-revoked certificate may still be signing builds on someone's Mac or in CI, so check your pipelines before deleting it.

What happens if I delete a private key from my keychain?

The certificate stays valid, but that Mac can no longer sign with it. Xcode reports the identity as missing a private key and refuses to build for distribution. If no one else holds a copy and there is no .p12 backup, the key is gone for good: Apple never had it and cannot reissue it, so the only path forward is revoking the certificate and creating a new one from a new key.

Why does macOS keep asking permission to use my signing key?

The key's access control list does not yet trust the tool asking for it, so the keychain prompts with codesign wants to sign using key in your keychain. Clicking Always Allow fixes it interactively. On a build machine there is nobody to click, which is why CI scripts run security set-key-partition-list -S apple-tool:,apple: -s -k <password> <keychain> after importing a .p12, so signing proceeds without a prompt.

Can two developers use the same private key?

Yes, and for distribution certificates it is the normal arrangement. Export the key and its certificate together as a password-protected .p12, share it through a secret manager rather than chat or email, and each person imports it. What you should not do is have several developers each generate their own key for the same certificate type, since that leaves the team with multiple distribution certificates and profiles that only match one of them.

Can I recover a lost private key from Apple?

No. Apple only ever receives the public half, inside your certificate signing request. The private key is generated on your Mac and never leaves it, so Apple has nothing to send back. Recovery means revoking the certificate, issuing a new one from a new key, and regenerating every provisioning profile that referenced the old certificate.

Keep reading

Related terms

Next step

Help articles on this topic

Notice a definition that has drifted? Email support@hexsign.io and we'll update it. Browse the full glossary or jump to the help center.

Try HexSign

Know before a certificate or profile expires.

HexSign tracks every Apple certificate and provisioning profile and alerts you ahead of expiry. The Free plan covers tracking and alerts. Paid plans renew them for you.