Xcode Code Sign error because of no Keys in Keychain - ios

You might think, not again such a question where are already thousands of topics about. However, I've not been capable of finding the answer I needed to fix this problem.
None of these topics go as deep as the Keychain.
When I'm trying to deploy my app to an iPhone, I'm receiving the following message:
Code Sign error: The identity 'iPhone Developer: [Name] ([ID])' doesn't match any valid, non-expired certificate/private key pair in your keychains.
Now, as said, I have been looking for multiple guides or fixes, however, none of them seemed to fix this issue.
Things I've tried:
Use Apple's walkthrough for app deployment for countless of times
Searched the internet for guides for app deployment
Changed the content of the 'pbxproj' file inside the 'xcodeproj' package.
Retrieve all available profiles from Apple's server using the Refresh button in Xcode 4.6 (allows you to obtain automatically)
After trying all of these ways, I've still not been able to solve the issue. One problem I've seen is that at first hand, the certificate in the Keychain was showing an invalid status, which is now solved.
However, if I'm right, there are supposed to be two keys attached to the certificate. A public and private key, and these are not showing.
Neither are there any keys showing in the Keys tab in the Keychain Access.
Solution
(Thanks to nsgulliver)
Do everything what the post (marked as Solution) of nsgulliver says.
If you already have an active Certificate, click the Revoke button, this won't cause any trouble, you'll simply have to re-create the keys of which then will be generated a new certificate.
Make sure you have the WWDR of Apple installed to mark the certificate authority as valid.
Follow the default Provisioning Assistant guidelines.

Provisioning profiles installed on the devices or signed with for the target might not be valid, try to go to Organizer->Provisioning profile and see if the profiles have the valid status? if not try to delete & refresh them, if they appear valid after refreshing then it might solve your problem if not then you should remove all the entries from keychain and delete profiles on your provisioning portal and try to create from scratch, if you still face the problem then take help from step by step guide tutorial

You cannot re-create matching keys, that would defeat the whole purpose of them. You need to find the old keys or start the signing procedure from scratch.
Are you using the same machine that you generated the keys on? If not, go to the other machine, export the developer profile, then import it on the new machine.
Can you restore the keys from backups? If not, stop everything you are doing and configure your computer for backups before you do anything else.
If you are really stuck, you will have to follow the signing procedure right from the very beginning, where you request a certificate from a certificate authority. This will generate new keys, and you will have to create matching provisioning profiles, then set your application to be signed with these. Dlete the old provisioning profiles, they will be useless without the old keys.

You need to lock keychain. Please see screenshot:

Required reading when you're having code signing problems:
Technical Note TN2250: iOS Code Signing Troubleshooting
Nothing will help you more than really understanding what's in your certificates and what isn't, where the necessary pieces are kept, and how they're used. This isn't the last time that you'll have code signing issues, and this tech note provides a long checklist that should help you make sure that everything is in the right place to help you develop your app and ultimately sign and submit it to the app store.

When I've had this problem in the past I've just deleted everything on my local machine and started again. So:
Delete the keys associated with your developer account in Keychain access.
In XCode open the 'Organizer' (window->organizer)
In Devices (top menu) and Provisioning Profiles (left menu), select all of the profiles and delete them.
Now hit refresh. It will ask you to sign in and whether you want to generate new keys etc, select yes and wait.
I find that this is the quickest way to fix any provisioning / key problems, as you can spend hours finding that you've missed something small.

After removing all old provisioning profiles (~/Library/MobileDevice/Provisioning Profiles/) and updating xCode, the certificates can be found again.

Related

Xcode 6.3 - You already have a current iOS Development certificate or a pending certificate request

Xcode as of 6.3 is no longer allowing me to automatically perform device provisioning for a client. Has anyone else experienced this issue? I found no results when searching for this on Google...
This client has their own bundle ID and it's possible they also have their own provisioning profile for this device. So maybe Apple is matching up the bundle ID irrespective of the developer account being used for provisioning.
I was able to address the issue by modifying the app's bundle ID and manually going through the provisioning process, but I'm guessing this issue is extremely rare, so I'm not sure if this post will be of use to anyone.
When I am create new certificate from my Xcode 9.2 the error was appear
"You already have a current iOS Distribution certificate or a pending certificate request".
Just 2 step for fix this error.
Remove old certificate from developer.apple.com
Create new certificate from Xcode or developer.apple.com
My problem has been solved (I am using Xcode 9.2).
I just found that if I remove my account from Xcode, and then sign in again, it solved the issue. I did revoke my existing certificates and request new ones though as part of that process. I didn't import an existing profile.
My team has maxed out on release certificates, because apparently there is a quota.
We had to delete one of the existing release certificates.
This issue is actually more common than you think.
Some Solutions:
I usually find that opening Xcode's settings and signing out of my account and the signing in again resolves most of those issues.
You may have an older mac that already used up that one allotted development certificate. In that case you'll want to export the developer profile from that machine. If you no longer have access to that machine, it may be time to invalidate that certificate and simply request a new one.
Another option may be to double check your build settings in your project and ensure that it's looking for the right certificate. It's fairly common in my experience for these settings to make decisions on their own, and confirming that they're what you expect may help.
Background:
When dealing with provisioning, it's really easy to get caught up with the frustration of all of the steps you need to go through. The first thing to note is if the error you see is talking about a "Certificate" or a "Profile." In your case, it's a certificate. Good.
Certificates differ from provisioning profiles in a few ways. Certificates are usually only generated twice: once for development, and once for distribution. (Exceptions to this rule are if you decide to add support for some of the special features like push notification or for generating passbook passes on a server.)
The process for generating certificates is also a little more bureaucratic than profiles. You request a certificate from Apple's Member Center. You generate a provisioning profile.
The reason for the word request vs generate is because both Apple and your iOS team's admin need to approve certificate requests. This is because certificates identify you as part of your iOS developer team, and offer all the powers associated with that.
For the sake of completeness, I'll add that provisioning profiles are generated based on that certificate, and really only tell iOS what environment your app is meant to run in. (On any device via the store, specific devices, etc.)
Now, the important part for you is the request business. Most people don't pay much attention to this terminology, since indie developers and small teams (where the developers are admins) don't require developers to ask for permission.
Your error is talking about a previously generated certificate or request. You can only have one development certificate per developer. You either have one, or you've requested one and someone has to approve.
That's what's happening here.
This process is made simple with Xcode 8.3 and 9. Just delete one of your old certifcates in the "validate" interface and click the plus button to request new one, Xcode will request for you and add it in keychain. in my case, maximum number was reached, so I deleted one which was lost in a old Mac and created new one.
This error may also be occur if you reach your distribution certificate limit. After creating 3 iOS Distribution Certificates in an account, the following error message will be displayed when you try to create 4th one: "You already have a current Distribution certificate or a pending certificate request."
Open this link
https://developer.apple.com/account/resources/certificates/add
Press + icon in front of Certificate
Check Apple Distribution section if its show the red text as shown in image then you should revoke you existing certificates to generate new one because you have reached you limit.
Just 2 step for fix this error.
Remove old certificate from developer.apple.com
Create new certificate from Xcode or developer.apple.com
Delete old developer certificate from https://developer.apple.com/account/ios/certificate/ and try to create developer certificate from xcode
1) Remove old certificate from apple developer account.
2) Go to the 'Xcode' 3) Select 'Preferences' option and then Select the 'Account' Tab
3) Select apple id from left side and click on 'Manage Certificate'.
4) Click on '+' (add certificate) button.
5) Add 'Apple Distribution' Certificate.
Unfortunately, only a macbook restart resolved this for me.
Creating another Distribution certificate was not an option, because it had already reached the max. number of certificates.
I manually added an existing one (incl. its private key) to the Keychain …and still Xcode said "Not in Keychain". I then tried to trigger a refresh of the Xcode listing by removing & adding my developer account to Xcode, but that didn't work — neither did restarting Xcode.
So, when all else fails, you try to reboot your system.
When you have three active distribution certificates that were created on distinct machines, you'll see this issue. You can either ask for the private key of a previously made one or simply revoke any of them and make your own.

"The private key for ... is not installed on this Mac" – distribution and provisioning profiles in Xcode

I've tried looking at the other answers for this but there's a lot of incomplete or conflicting information, but if you have a good link that would be great.
When I try to distribute my app I get this error:
I've tried creating a new distribution profile from Certificates, Identifiers & Profiles at developer.apple.com, but none of these seem to work.
I have a Time Machine backup from before I did a clean install of Mavericks to upgrade, and I also have a code saved to a text file in my Dropbox (I'm not sure if it's a private key – I doubt it) which looks like 'df9a79...' around thirty characters long.
I just can't seem to find the right link to guide me through the entire process of key creation, iTunes connect and developer.apple.com. I've done this before – I'm currently just trying to submit an update to the App Store.
My app update status is currently Waiting For Upload.
Here is my Keychain:
I've tried removing duplicates (e.g. those in the first screenshot), but that didn't seem to help. If you have any suggestions or links I'd love to hear them.
Thanks for your help.
In your keychain, there are two keys named 'Matthew Palmer'. Those two entries for the same name can be conflicting. Try by removing those both and install it again.
I hope you make a Distribution Provising Certificate at developer.apple.com.
Chose that profile there , if you are not, create that, first you need to create that certificate before proceeding.
I had this problem and eventually realised that I'd originally installed my provisioning certificate on another machine. The private key was only on that machine, and there was only a public key on my new machine. I needed to install my private key on my new machine so I could sign my app and submit it.
On my original machine, I went to Xcode>Preferences>Accounts and used "Export accounts" (under the cog) to save a copy of my accounts. I transferred the generated .developerprofile to my other machine and dropped it on Xcode there. That installed the private key for the provisioning profile on that machine and I was able to submit my app.
Another resolution to this is restart Xcode. I had the same issue after creating a new provisioning profile, and after restarting Xcode I no longer had the issue.
After experiencing this error, I tried submitting to the app store via Application Loader, signing the app with my AdHoc certificate instead of the app store certificate, as that one didn't generate the same error.
The submission was accepted by Apple with no validation errors.
This is a temporary workaround, but it may be helpful if you need a quick submission.

Certificate identity 'iPhone Developer: ' appears more than once in the keychain. The codesign tool requires there only be one

Ok, I am completely pulling my hair out on this one.
Back in July I created a provisioning profile so I could test on my iPad.
Then at the end of August I tried submitting my first App to the iTunes Store. The process was a complete nightmare, and I struggled. A lot. In the end I found a tutorial with relatively recent information in it, and only by following it step by step could I actually get anywhere with this. Unfortunately the result of this was that I created a new provisioning profile.
Now when I try to test on my iPad I get the following error in Xcode:
Certificate identity 'iPhone Developer: MyName' appears more than once in the keychain. The codesign tool requires there only be one.
I check the keychain, and sure enough there are the two provisioning profiles for development, one from July and the one I used to submit to the iTunes Store in August.
Now what I want to do is get rid of the old one, and then connect my iPad up to the new one. I can get rid of the old one fine, but I cannot connect my iPad to the new one, it insists on using the old profile, even to the point of re-attaching it to the keychain after Ive deleted it.
Can anyone tell me:
How to connect my iPad to the new provisioning profile?
And while we are at it, can anyone shed any light on why this entire process is so convoluted and difficult? Considering that so much of Apples interface is so well designed and fluid, this process of registering certificates and applying them to different devices and Apps seems so backwards. I initially suspected this was just me, but googling for these error messages reveals that there are many who are struggling at various points along this process.
This has nothing to do with Xcode and everything to do with keychain.
Open keychain.
Find the signing certificates that are tied to your provisioning profiles.
Delete one. You probably want to keep the newer one, so look at the expiration dates and remove the one that expires first.
Restart Xcode
You may need to update your provisioning profile if it isn't tied to the new certificate, but it won't be as painful as creating a new certificate.
Here's a broad overview of how code signing in Xcode works. It a bit much but will explain what's wrong with your configuration, and how you can fix it.
There are three parts to the mechanism that ensures that you are who you say you are and that your app is allowed to run where it wants to.
You've got a pair of keys, one public and one private. Your public key matches your private key, which identifies you.
Your keys are used to generate certificates. Generally, you'll have one certificate for development and one for distribution,either on the App Store or via Ad Hoc distribution. These certificates permit you to provision your apps.
Each certificate is used to generate provisioning profiles. The profiles must be attached to either a development or a distribution certification. A distribution profile either works on the App Store, or it contains a list of device IDs which may run apps signed with that profile.
If your certificate is expired, the provisioning profiles that are created with it are going to be invalid. In this case, replace both the certificate and the profiles. Generate a certificate signing request (CSR) from Keychain Access and upload it to the developer portal.
If you have multiple certificates in your keychain, Xcode won't know which one to use. This may happen if you renew your certificate and don't remove the old one. (It may also happen if you exported your developer profile and then imported it later. Your old certificates will carry over.)
If your provisioning profile is expired or invalid, you can renew it in the developer portal without generating a new CSR. You can just attach it to an existing valid certificate.
Certificates can't be carried over from one machine to another without moving the original key pair that requested it. Exporting the certificate from Keychain will export the keys as well.
Delete the old one, and start build with new.
One more way you can try , set code signing identity with profile you want to run in both target as well as project build setting.
Hope it will help you.
Otherwise you have to delete old one.

No value was provided for the parameter 'appIdName'

Whenever I try to do anything with provisioning, adding devices to the portal, etc. get this error msg:
No value was provided for the parameter 'appIdName'.
I have seen this post:
No value was provided for the paramenter 'appIdName' when provisioning
however this does not apply as I have followed the instructions without any success. I must create my Team Provisioning Profile manually (and any others as well) for anything to work. This is a pain and even adding a device throws this error. Any idea what is going on? Is this a common issue for others developing in iOS? I've been working in iOS for 4 years now and never ran into something like this.
My profile was set to expire. I hit renew, and got this error, followed the above article with nothing helping.
I've been having the same problem for days. I followed the instructions in the other post (No value was provided for the paramenter 'appIdName' when provisioning) with no luck. Here is what worked for me:
open keychain access
select "login" from the keychain category
select "My Certificate" from category
Delete all your certificates associated with the provisioning profile.
What I also did is clean up everything in my provisioning portal. I revoked all certificates (distribution and Development) and all provisioning profiles.
Open up organizer in Xcode, select provisioning profiles in the top left, and click refresh.
Follow the instructions to create new profiles and certificates.
Hope this helps.
I had the same problem as well and what worked for me was to follow the instructions here:
https://developer.apple.com/ios/manage/overview/index.action
And then launch the assistant. These steps seem more current than the ones that described here:
Manage Your Workflow in Xcode - Test Your App on an iOS Device
Hopefully this will help out others.

iOS provisioning code signing problems. How can I wipe everything out and start over?

I am having real trouble with provisioning and code signing issues. I have migrated to a new computer and have a bunch of "Valid signing identity not found" messages. In repeated attempts to fix distribution code signing I have managed to lose my developer code signing as well.
I am the first to admit that the root problem is my complete and utter failure to grasp the concepts of code signing, provisioning, and all related subjects. I am asking a separate question on SO to address this.
THIS question is to ask for concrete steps to wipe my provisioning and code signing mess completely clean. I am running Xcode 4.3 and have 2 live apps in the App Store that I do not want to interrupt the distribution of. Please help.
Update: I have imported my private key from the old mac, and it is showing in Keychain Access. When I try to request a certificate according to Apple docs, I don't get a "Let me specify key/value" checkbox, and when I try to save it to disk anyways I get the error "the specified item could not be found in the keychain". Arrgh.
Step 1: Open XCode. In the Organizer, delete all provisioning profiles.
Step 2: Open Keychain Access (Utilities>Keychain Access); delete all certificates related to developer/distribution and the WWDCCA (or whatever it's called) intermediate certificate.
Step 3: Re-download and resign. Make sure you export and import your private key from your old machine to your new one.
If you need instructions on how to set up code signing, you can look at my answer to this question: Code Signing Error.
Cheers!
Have a look at this tutorial here. You may find this helpful
http://seventhsoulmountain.blogspot.com/2013/09/ios-code-sign-in-complete-walkthrough.html

Resources