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: 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
- Import the .p12 (cert plus private key) into the CI keychain.
- Add the keychain to the search list.
- Run
security find-identity -v -p codesigningand confirm one valid identity.
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.keychainPoint 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.