Search code examples
ioscode-signingcode-signing-certificate

ios certificate for code signing confusion


I am reading this article which explains code signing in iOS/OSX.

I understand that from KeyChain Access ultility I can see my certificate, if unfold my developer certificate, I can see there is a private key: enter image description here

The article says:

...you will find the certificates you have the private key for. To use a certificate for signing, you need the private key...

I understand this.

The article also says:

To export a certificate from your keychain with the private key,Command-Click the certificate and choose ‘Export...

which makes me feel the private key is injected inside the certificate.

But the article then says:

A certificate is — very broadly speaking — a public key combined with a lot of additional information that was itself signed by some authority

I get confused, the first quote says the certificate contains a private key, but the above quote says a certificate is a public key combined with other inforation. Where is the private key then???

Can I understand it like this:

A certificate is actually a public key which holds/nested with a private key? So, if I export the certificate, I am actually exporting both the public key and private key and other info in the form of X509 certificate?


Solution

  • If you are exporting the certificate, you are not including the private key (unless you select it as well). More information: https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppDistributionGuide/MaintainingCertificates/MaintainingCertificates.html

    The article is correct. The certificate, by itself, does not include the private key. However, in the article you are requested to select the certificate together with the private key and export it. When doing that, the private key is included in the .p12 file you are creating.