Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Code Signing on Mac "error: The specified item could not be found in the keychain"

I'm attempting to sign an application on macOS Sierra, but my Developer ID certificate(s) cannot be found. Can anyone clarify what I'm doing wrong? Thank you!

Here's my flow:

  1. I downloaded an "Application" and "Installer" Developer ID certificate from Apple
  2. I installed both to my System keychain, they show "This certificate is valid"
  3. I open Terminal and change directories to my application folder
  4. I try codesign --deep --force --verbose --sign "<identity>" "<appName>" but I get the following "error: The specified item could not be found in the keychain"

Some things I've tried:

a. Using custom settings for the certificates by setting Code Signing to "Always Trust"

b. Using the certificate's entire Common Name for the identity instead of the value inside the parentheses

c. Running security find-identity -p codesigning, I get the following "Policy: Code Signing Matching identities 0 identities found Valid identities only 0 valid identities found"

d. Deleting the certificates and reinstalling them to the login keychain

like image 818
Derek Parry Avatar asked Nov 22 '16 14:11

Derek Parry


People also ask

How do I get a certificate authority certificate on a Mac?

In the Keychain Access app on your Mac, choose Keychain Access > Certificate Assistant > Request a Certificate From a Certificate Authority. Enter your email address, name, and the email address of the certificate authority you want to issue you the certificate, then click Continue.

How do I add certificates to keychain?

In the Keychain Add Certificates window, choose login as the Keychain option and then click Add. Enter the password you used when you created the . p12 file and click OK. Verify that your certificate is installed in Keychain Access.


1 Answers

You didn't mention the private key you used to generate the cert in the first place.

I purchased a new Mac Mini build machine to replace an old one. The old one had the signing certs. Just importing the signing certs downloaded from Apple didn't work, I also needed the original private key from which the certificate request was formed. So I followed https://stackoverflow.com/a/34063997/28190 to export a new keychain from the old machine, imported to a new one, and then I was able to use that.

You need to customise your `unlock-keychain' calls to point to the imported keychain.

like image 133
Dan Gravell Avatar answered Oct 16 '22 11:10

Dan Gravell