Certificates, Provisioning Profiles, public/private keys demystified
code-signing-certificate, ios, objective-c, provisioning-profile, xcode
Solution
Ray Wenderlich has it explained reasonably well here. To improve your description, instead of
The 'recognized certificates' have references to the public key, while the private key is essentially passed on by the app.
I would say:
The app .ipa includes a developer certificate. The developer certificate is signed with your private key - as well as with the official Apple private key.
Thus, by verifying the developer certificate with Apple's and your public keys, the iPhone can verify that:
- you are the developer of this app
- you have been certified by Apple for app development
- this app is allow to be run on the iPhone (as long as there is a provisioning profile on the phone that refers to this developer certificate).
Your private key is not stored in any of the certificates or profiles, it is only used for signing. Not sure whether the public keys are stored. In order to be fully secure, the phone should fetch the public keys from Apple when verifying.
Problem
This topic continues to confuse me. I thought I'd write out my current understanding and hopefully find out the things I'm right about/things I'm wrong about. When you create a development certificate, there is a concept of a public and private key. The certificate available thru the provisioning portal holds on to a public key, while your private key is stored within your keychain. In order to code sign your app, you've got to have both. In order to run an app, the device must have a provisioning profile, which essentially holds on to an app identifier, a set of recognized certificates (the app must've been signed by one of these certificates), and a set of device identifiers (which indicate which devices are allowed to run the app). The 'recognized certificates' have references to the public key, while the private key is essentially passed on by the app. Thus, with regards to the App Store, we can think of a normal device as coming with a default prov profile that already has apples 'public key' and apple performs their own code sign operation before distributing whereby they add their private key. Perfect? Close? Way off? Insane?