The other thing to check is to make sure the keychain that certificate in is unlocked.
# Get the path to the keychain
security list-keychains
# Unlock the keychain
security unlock-keychain -p <password> /path/to/keychain
Topic:
Code Signing
SubTopic:
Certificates, Identifiers & Profiles
Tags: