Skip to content
Latchkey

macOS runner: "The specified item could not be found in the keychain" in CI

A signing or lookup step asked for an identity that is not in the keychain it searched. Either the certificate import never succeeded, the private key is missing, or the identity lives in a keychain not in the search list.

What this error means

codesign or security find-identity reports "The specified item could not be found in the keychain." or returns 0 valid identities.

security
security: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.

Common causes

The certificate and key never imported together

Importing only a .cer (no private key) leaves no usable codesigning identity, so a lookup finds nothing.

The identity is in a keychain not being searched

The .p12 imported into a custom keychain that was never added to the search list, so the default lookup misses it.

How to fix it

Import the .p12 and verify the identity

  1. Import the .p12 (cert plus private key) into the CI keychain.
  2. Add the keychain to the search list.
  3. Run security find-identity -v -p codesigning and confirm one valid identity.
Terminal
security import cert.p12 -k build.keychain -P "$P12_PW" -T /usr/bin/codesign
security list-keychains -d user -s build.keychain login.keychain
security find-identity -v -p codesigning build.keychain

Point the signing step at the right keychain

Reference the keychain that holds the identity, or add it to the search list, so codesign can find it.

How to prevent it

  • Import a .p12 that contains both certificate and private key.
  • Add the CI keychain to the search list before signing.
  • Verify identities with security find-identity -v -p codesigning.

Frequently asked questions

What causes ""could not be found in the keychain""?
Importing only a .cer (no private key) leaves no usable codesigning identity, so a lookup finds nothing.
How do I fix "could not be found in the keychain"?
Import the .p12 and verify the identity

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card