"Unknown Error = -2,147,414,007" on creating certificate with Certificate Assistant I am getting &quot;Unknown Error = -2,147,414,007&quot; on creating a certificate through the Keychain app.

Steps to Recreate:

Open the Keychain Access application. Select Certificate Assistant &gt; 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

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

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

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.

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.
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 &amp; 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:


Keychain Access error when creating new system certificate
https://gist.github.com/hlissner/898b7dfc0a3b63824a70e15cd0180154