Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I fix "Missing Private Key" for xcode apple provisioning?

On a new mac, I installed xcode and needed to set up provisioning for a hello-world project to deploy to my iPad.

NOTE: I am using the new FREE provisioning (do not have a paid Apple account)

  1. I went to Preferences/Account signed in to my Apple account
  2. In the project, General tab, Team is set to my (free) Apple Dev account. (all seemed well, it recognized this as valid)
  3. I tried to deploy to the iPad and I got a build error "codesign failed with exit code 1"
  4. Supposedly this is to do with certificates. I went to Keychain Access and found "iPhone Developer: [email protected] (...)" in there, which was added when I signed in via my Apple Account.
  5. I DELETED this key (thinking I would simply re-add my Apple Account and thus this key)
  6. I then removed and re-added my Apple account from xcode preferences
  7. I can sign-in, I can see it adds keys, and Keychain Access Get Info on the keys indicates no issues (valid, etc)
  8. In xcode Preferences, when I click Manage Certificates, it shows "David's MacBook Pro (2)" and a bunch of "Untitled" keys ALL of which have a status of "Missing Private Key".
  9. xcode/General/Status section says "The username or passphrase you entered is not correct" even though my "Team" is signed in and valid
  10. Clicking "Try Again" shows "Waiting to repair", followed by "revoking...", followed by "Generating certificates" - which sounds promising, like it's doing exactly what I need, but then fails, private keys still missing, and back to step 9 here in a loop of hell.

ok? How do I get this resolved without flattening my OS back to factory and starting completely over?

Note: there are resolutions on SO that talk about Revoking the keys and generating new private keys from the Dev Console, like this one: How can I add private key to the distribution certificate?

HOWEVER, on a "free" account I have NO access to the Certificates section! I can't manage anything from the Dev portal online. I do, however, see xcode specifically set up to handle certs (see step 9-10 above) but it is not working. I really don't know where to go from here. I'm new to all things Mac and iOS and xcode. Frustrated. Thanks Apple, so much for a simple on-boarding experience on a simple hello-world app.

like image 383
dapug Avatar asked Feb 12 '18 18:02

dapug


People also ask

How do I get a private key for Apple distribution certificate?

Click on the plus sign to add a new certificate. Select "App Store and Ad Hoc" option, and click Continue. Follow the steps printed in the webpage. That involves opening the Keychain application on your Mac and generate a Certificate Signing Request from there.

How do I find the private key of a certificate?

Windows (IIS) On Windows servers, the OS manages your certificate files for you in a hidden folder, but you can retrieve the private key by exporting a “. pfx” file that contains the certificate(s) and private key. Open Microsoft Management Console (MMC). In the Console Root expand Certificates (Local Computer).

What is a private key in Keychain?

A private key, also known as a secret key, is a variable in cryptography that is used with an algorithm to encrypt and decrypt data. Secret keys should only be shared with the key's generator or parties authorized to decrypt the data.


1 Answers

After two bounties for this question which gave no results, I managed to find a solution to this problem. Apparently, it was some keychain related problem.
To fix it:

  1. Open Keychain Access on your Mac.
  2. Right click on the "login" keychain in the left side of the window.
  3. Press Lock keychain "login".
  4. Then do the same to Unlock it.
  5. Go back to Xcode and try to set your app to run with your personal account.

Solution was found using the first comment here: https://github.com/desktop/desktop/issues/3625

like image 142
resurrecteds Avatar answered Oct 06 '22 17:10

resurrecteds