How to create a new identity in macOS?

I've done likely stupid things in Keychain Access and now I don't have access to identities:

user@host:~$ security find-identity

Policy: X.509 Basic
  Matching identities
     0 identities found

  Valid identities only
     0 valid identities found

I've imported my certificates from developer.apple.com, but identities are still not shown. I think I'm missing private keys, but I don't know what to do.

I don't seem to have developer IDs in place:

user@host:~$ sudo certtool y | grep -i dev
   OrgUnit         : Apple Worldwide Developer Relations
   Common Name     : Apple Worldwide Developer Relations Certification Authority
   Common Name     : iPhone Developer: ...
   OrgUnit         : Apple Worldwide Developer Relations
   Common Name     : Apple Worldwide Developer Relations Certification Authority
   Common Name     : iPhone Developer: ...

How can I restore identities?


Solution 1:

Adding the correct developer identity preferences is done in Xcode.

  • Open Xcode
  • Select Preferences in the Xcode menu.

enter image description here

  • Click "Accounts"
  • If your developer Apple ID is not listed click on the "+" on the left and add it.
  • Click on the Apple ID and then "Manage Certificates". This will allow you to create the various required signing certificates.