Assuming that you’ve just installed a fresh Snow Leopard on your Mac. If you want to use again your iPhone for developing you have to import your personal iPhone public and private development key into the keychain. (Given that you’ve hopefully created a backup of your keys before reinstalling
). Unfortunately it’s currently impossible to import these certificates via a double-click or a drag & drop action etc. The keychain always prints the following annoying error message:
An error has occurred. Unable to import an item. The contents of an item cannot be retrieved.
But don’t worry! There is a simple workaround available. Just start the Terminal.app and use the following commands to manually import both keys. Please replace priv_key.p12 and pub_key.pem with your personal key files. That’s it!
1 2 | security import priv_key.p12 -k ~/Library/Keychains/login.keychain security import pub_key.pem -k ~/Library/Keychains/login.keychain |



Oh oh oh, you’re a genius. Keychain Access barfs, so I’m running this command and thinking it’s not working — but then, oh wait, the private and public key are now there. Thank you, thank you, thank you. It worked.
This is still a problem today. If you have to exchange credentials for developing iOS applications, I suggest creating a dedicated keychain to hold all public and private keys and certificates. Then just zip up the keychain file and send that around. It’s much better that having to re-explain this 3 year old issue time and time again.
Thank you so much for this. I know it’s years later, but trying to transfer keys between two mountain lion boxes I ran into the exact same “unable to import” issue. Thank the dear fluffy lord that this page showed up in the google search — running the import through terminal worked great.
Thanks!!
I can’t understand why isn’t the issue on the Apple Reference Document.
Thanks for this
Thanks, this saved my day! I was able to recover my private key I accidently deleted from an old pem file.
Thank you! If you forget to put the -k (like the example shows) it will not work. I had to double click my private key files to get them to go; the security command as typed did not prompt for a password. (10.6.7)
Thank you!!!
Thankz..buddy …it works fine
Amazing how this is still current! Thanks a lot, and hope they fix it in Lion.
Any info on why this error occurs generally. Need to prevent it.
Nope. Maybe it will be fixed in Mac OS X Lion.
– Stephan
Thank you for such a valuable post….Saved my day…..May God bless you..
Hey thanks you very much. I was scared when I saw the error on my mac. “And now what I have to do??”
With your info I solved it quickly. Great!!!
- magi
Had the same problem, thank for the trick Stephan!
Also it seem that some project preferences did not copy correctly. So, after importing the keys, I had to check the menu “Edit Project Setting” -> “Build” tab -> “Code Signing identity”. Also my info.plist file had to be reviewed, some variables are managed by Xcode so I had to reset it in order use the same application profile.
If this can help others…
I had the same problem. I attempting to bring some work home. At work we use 10.5, at home I have 10.6.
I did as you suggest, but still get the error.(Not the warning, though)
In “Organizer/iPhone Development/Provisioning Profiles”, the yellow tab says “A valid signing identity matching this profile could not be found in your keychain.”
In Keychain Access, the Certificate appears under “Certificates” and the Key appears under “Keys”, but they don’t seem to be linked together: None of them show disclosure triangles.
(I have another Certificate/Key for MobileMe and these DO show each other on disclosure).
Also, I only exported the private key (.p12 file), NOT the public key (.PEM file), Is this wrong? Now it’s weekend and I’m at home, I am stuck to iPhone Simulator until monday…
WHY DOES IT HAVE TO BE SOOOOO COMPLICATED?
What did I do against Apple? (laughs, anyone?)
Figuring out -viewDidUnload and -didReceiveMemoryWarning was a lot easier…
Hi Nicolas,
Yep, that’s most likely the crux of the matter. You must import your private (P12) und public key (PEM) ’cause both keys form the so-called “valid signing identity”.
That’s right! In many cases developing for other (mobile) platforms is not that tricky.
– Stephan