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

IphoneObjective CCocoa TouchXcodeProvisioning

Iphone Problem Overview


> Possible Duplicate:
> Xcode - iPhone - profile doesn’t match any valid certificate-/private-key pair in the default keychain

I'm having a problem installing a provisioning profile created by another developer.

  1. Development Certificate already exists
  2. App I'm working on has a Provisioning Profile associated with the certificate
  3. My device UUID has been added
  4. AppID for the app already exists
  5. Development Provisioning Profile exists, with my UUID

When I download the Certificate and Provisioning Profile I get the error in Organizer:

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

How can I resolve?

Iphone Solutions


Solution 1 - Iphone

You also need the private key that was used when requesting the certificate.

The private key is what is used for signing every device binary you compile using that developer identity. The certificate you download and import is basically just a stamp on your private key saying "code that is signed using this key is allowed to run on a device".

Have the other developer export the keys used when generating the original certificate signing request and then import them on your machine.

Look in Keychain to see if the key is correctly paired with the certificate once you have both:

When everything is correctly in place you should see a little disclosure triangle on your certificate which lets you see the key (and vice versa on the key page where you should see the certificate under the key). Otherwise the relationship is not correct, not recognized by Keychain during import (I have seen this in some cases when importing a renewed certificate while the expired one was still in the keychain).

I was recently trying to move the public/private key pair for an iOS developer certificate to another machine. The public file was exported using Keychain Access to .pem and the private file to a password protected .p12.

On the other machine Keychain Access would not import them. The solution was the good old command line:

security import ios_priv.p12 -k ~/Library/Keychains/login.keychain 
security import ios_pub.pem -k ~/Library/Keychains/login.keychain

So try this if you have problems transferring the keys for your certificate.


EDIT to reply to @baudot's comment below. (It wouldn't fit in a comment)

Make sure you also have the Apple Developer Relations Root CA certificate in your keychain. That is what is used to verify the certificate.

You could also opt for a fresh start. Just delete the keys and certificates from your keychain, revoke them on the ADC portal and delete their associated provisioning profiles.

Once you have removed everything you can generate a new key pair and associated certificate signing request. Then make sure to export the keys and stash them in a good place for the future.

Then you go to the ADC portal, upload your new cert signing request, generate new provisioning profiles and you are good to go.

The only irreplaceable thing is your ADC account. All the rest can be restored or recreated.

I would also recommend that you use the fancy new automatic provisioning built into Xcode. That saves you the headache of downloading and importing the provisioning profiles. It simply syncs your existing ones with ADC.

Solution 2 - Iphone

This happened to me because I dropped the profile onto the device's Provisioning Profiles section in the Xcode Organizer, but not into the Library's Provisioning Profiles section. Once I dropped it there too, the warning disappeared in the device section.

Hope this can help anyone...

Solution 3 - Iphone

When the certificate is OK, restart Xcode to help it find it.

Solution 4 - Iphone

I had a similar problem. One solution is to delete the certificate from your keychain and request a new one. Apple has a really detailed walkthrough here:

technotes

Solution 5 - Iphone

I had this issue after my certificate expired and was certain the keys were all good and in the right places. The step I was missing was deleting the profiles in the Provisioning Portal and recreating them. Don't trust that "renew" link - it looks like such a tempting shortcut, but it just didn't work for me!

So, for a fresh start, not only do you need to delete the keys and certificates from your Keychain, you need to wipe the contents of the Development and Distribution tabs under Provisioning.

Solution 6 - Iphone

I also had this problem on 10.6, Xcode 4.2. After trying many other things, I finally just exited Xcode and restarted it. Then the error message went away. Got figure.

Solution 7 - Iphone

I have only been able to solve this by using Xcode -> Organizer -> Developer Profile and there clicking Export in the bottom of the right pane. This saves a consolidated .developerprofile file that you cat just open/import on the target machine.

Disclaimer: this may arguably not be what the poster originally intended to achieve. I have however not been able to successfully move private+public+cert between my machines any other way.

Solution 8 - Iphone

You have to edit you provisioning profile in iOS provisioning portal. Select "edit" button and then "Modify". Enter the required info (your name, devices, appl. id).

When the system shows that the profile is "Active", go to Certificates section of the iOS provisioning portal and check your development certificate. It should have your provisioning profile listed in the "Provisioning Profile" entry.

After then, you can download the profile and drop it into Xcode.

Solution 9 - Iphone

If your old mac is not accessible, but you have ssh access (like powered on in an office cube far, far away), there is a solution. You can simply copy the keychain from your old machine to your new machine using the command line:

scp user@oldmac:Library/Keychains/login.keychain ~/Downloads/oldmac.keychain
--or-- ssh oldmac; cp Library/Keychains/login.keychain ~/Dropbox/oldmac.keychain

On the new Mac, open Keychain Access. Go to File -> Add Keychain and choose Downloads/oldmac.keychain

Then simply copy the necessary public keys from the oldmac keychain to the default "login" keychain.

Solution 10 - Iphone

Just had this problem now.

Simply hit "Refresh" on the bottom toolbar and XCode 4 will download and install everything for you.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSheehan AlamView Question on Stackoverflow
Solution 1 - IphoneHeibergView Answer on Stackoverflow
Solution 2 - IphoneMathieu FrenetteView Answer on Stackoverflow
Solution 3 - IphoneMatthew MitchellView Answer on Stackoverflow
Solution 4 - IphoneNate SmithView Answer on Stackoverflow
Solution 5 - IphoneChris NewmanView Answer on Stackoverflow
Solution 6 - IphoneTony PerezView Answer on Stackoverflow
Solution 7 - IphoneconnyView Answer on Stackoverflow
Solution 8 - IphoneHynekView Answer on Stackoverflow
Solution 9 - IphoneStickleyView Answer on Stackoverflow
Solution 10 - Iphoneuser1401452View Answer on Stackoverflow