Xcode could not find a valid private-key certificate pair for this profile in your keychain

Solution 1:

The best thing you can do is delete the certificates from your Keychain and get them back so XCode 4's Organizer stops being "confused". I've compiled it in 7 "easy" steps:

  1. Delete your Certificates: Open the Application called Keychain Access on your Mac (You can hit the keys command + space bar on your keyboard to bring Spotlight and type Keychain Access to launch it). Then select login on the upper left list and Certificates on the lower left list, you will delete only the Certificates starting with the words "iPhone Developer" or "iPhone Distribution".

  2. You need to revoke the old certificates by logging into your Apple iOS Developer's account and going to the Provisioning Portal and then to the Certificates option on the left menu. Then locate your Developer Certificate and click on the link located at the right that reads "Revoke".

  3. Go back to the Keychain Access Application on you Mac, click on the menu bar the following menus: "Keychain Access" -> "Certificate Assistant" -> "Request a Certificate from a Certificate Authority". Just enter you email if needed and modify the option that says "Request is:" selecting the option "save to disk"... a dialog will ask you where do you want to save a CSR file which is normally called "CertificateSigningRequest.certSigningRequest".

  4. Go back to the online Provision Portal and create a new Certificate uploading the file you just generated on the same option where your old Certificates were before.

  5. After a minute or so... you will see under the Certificates list that you can now Download you new certificate and that you can also download a WWDR intermediate certificate (See the links under the certificate list). Download them and give them to your Keychain Access by double-clicking them.

  6. You will have to go to the Provisioning Portal menu option called Provisioning where you will see all your App's Development Provisioning Profiles. You will have to click the link "Edit"->"Modify" at the right and verify that the Certificate is checked.

  7. Finally, just close "XCode 4". When you re-open it, go to the menu "Window" -> "Organizer". Because the Organizer reads the certificates from you keychain, they should be there already. Next time you plug your devices just click on Provisioning and make sure the old certificates are gone and the new certificate is on.

Solution 2:

For some reason, I found that Apple's root certs were not in my keychain. I can't explain why. but after about 3 hours of looking, I finally figured that out. I red-ownloaded them from here:

http://www.apple.com/certificateauthority/

Solution 3:

I ran into this same problem (switched to a different system) and at least as of Xcode 4.5.2 (possibly earlier), you can export your Developer Profile. To do so, open the Organizer, click on the Devices section, then go to the Editor submenu in the menu bar. There will be a Developer Profile entry that has Import & Export actions. Export the profile from the previous system and then import it on the new system. You can password protect it, so you could also just put it into your SVN/git/whathaveyou so it's available across systems.