“CodeSign error: Certificate identity … appears more than once in the keychain. The codesign tool requires there only be one.”

One morning last week, I fired up Xcode4, and all projects were refusing to build. The Apple Developer certificate had expired (why does Apple make this expire *earlier* than your annual iOS $99 subscription? Odd).

Anyway, a quick trip the Apple Developer Portal, and the Provisioning page, one-click “renew” certificate (free), 30 seconds refreshing for Apple to process it, re-download, delete the old one (using the Apple app: Keychain Access), install the new one, re-build.

FAIL

…only to be hit by this error message:

“CodeSign error: Certificate identity ‘iPhone Developer: XXX (YYY)’ appears more than once in the keychain. The codesign tool requires there only be one.”

What?

I just deleted that, in Keychain Access. I selected the one that was expired (it’s highlighted with a red error icon), and hit delete. It then disappeared. And allowed me to install a new one.

Xcode4: Clean, re-build. Nope, still refusing
Xcode4: restart, delete all build directories. Nope, still refusing.

Symptom: Apple’s “delete” does not “delete”

It’s a bug – a HUGE bug – in Keychain Access (Apple’s app that is part of OS X).

When you hit “Delete” (either the delete key, or right-click and select the Delete menu item) … Apple 50% of the time doesn’t process the deletion.

However, 100% of the time, Apple makes the item disappear from the screen.

To check if it’s deleted, close Keychain Access and re-open. If the delete was ignored, then you’ll see that the certificate you deleted has RE-APPEARED:


(third-from-the-bottom, you see the cert I had already deleted … has come back from the dead)

Solution: Delete and delete and delete until Apple stops ignoring you?

I’ve found that if you switch to the “All Items” view, on the left hand side, the deletion seems to work every time. But maybe that was just blind luck. Even if it fails, the act of switching back and forth between “All Items” and “My Certificates” seems to force KA to refresh the view, and tells you if the delete has “worked” yet:

18 thoughts on ““CodeSign error: Certificate identity … appears more than once in the keychain. The codesign tool requires there only be one.”

  1. thanks for the post, deleting the old expired developer certificate from the keychain worked for me.

  2. I was having a similar issue where it wouldn’t let me compile until I removed it. However, I have an additional problem where the certificate keeps getting back in the keychain somehow and I have not been able to determine how. Very frustrating.

  3. This worked for me! Thanks Adam.

    All the other posts on this subject seemed to focus on Xcode, and NOTHING was resolving the problem. Hard to believe it’s actually a bug in keychain, but your solution solved the problem immediately.

  4. I struggled to find the duplicate certificate. Finally did this and the duplicate, expired certificate showed up:

    Open up Keychain Access app within /Applications/Utilities and click “All Items” under the Category sidebar. Type “iPhone” into the top-right search bar.

    Exit, reopen Xcode and I could again build for distribution.

    Jim

  5. This worked for me, After delete all of unnecessary certificate. then re-open Xcode. Suddenly all the problem is solved ! Thanks, Adam

  6. Oh my God! Spent hours on this lazy issue and you got the solution. THANKS A LOT!

  7. Thanks for the tip! This worked well on snow leopard. However it is not working on Lion. Any tips on how to solve this?

  8. Many thanks, Adam. Worked for me – I was having this problem of reappearing distribution certificates in Keychain Access. Persistently deleting it and rebuilding the app worked.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>