“Unknown Error = -2,147,414,007” on creating certificate with Certificate Assistant

certificateerrorkeychain

I am getting "Unknown Error = -2,147,414,007" on creating a certificate through the Keychain app.

Unknown Error = -2,147,414,007

Steps to Recreate:

  1. Open the Keychain Access application. Select Certificate Assistant > Create a Certificate in the application menu (Keychain Access). Only Modified Parameters are listed. The remaining options are kept with default values.

    Name of Certificate = gdbcert
    Identity Type = Self Signed Root
    Certificate Type = Code Signing

  2. Check the Let me override defaults checkbox, and click Continue.

  3. On the next page, leave Security Number to be 1, and set Validity Period to 3650.

  4. Then click Continue once again, and keep doing so to skip the next six screens until you see the one entitled Specify a Location For The Certificate.

  5. For the only property, Keychain, choose System from the drop-down list. Lastly, click Create, type in your password, if prompted, and click Done.

Update: I'm able to create certificates to the Login Keychain. The issue is only when I try to create certificates for the System Keychain.

Best Answer

Was able to get this to work. The purpose for creating a certificate was to codesign gdb on Mac. Here are the steps for the same:-

  • Create a certificate with all the parameters mentioned above.
  • Instead of saving the Keychain under location System, save it under Login.
  • Then, unlock the System Keychain by clicking on the lock icon on the top left corner and drag the certificate from Login to System.
  • Right Click the Certificate, click on Get Info and and under Trust, set to Always Trust.
  • Restart taskgated in terminal: killall taskgated
  • Enable root account:
    Open System Preferences.
    Go to User & Groups > Unlock.
    Login Options > "Join" (next to Network Account Server).
    Click "Open Directory Utility".
    Go up to Edit > Enable Root User.
  • Run codesign -fs gdbc /usr/local/bin/gdb in the terminal.
  • Disable Root Account again and you should be good to go.

Credits: