Skip to content
This repository has been archived by the owner on Jun 19, 2024. It is now read-only.

Latest commit

 

History

History
63 lines (48 loc) · 4.49 KB

certificate.md

File metadata and controls

63 lines (48 loc) · 4.49 KB

Generate APNS Certificate

To push to your iOS/Mac App or to Passbook you'll need to generate an APNS certificate in the Apple developer portal. This page will guide you through this process.

Note that Apple also has some usefull instructions on Provisioning and Development.

1. Create a certificate signing request

You have two options to create your certificate signing request (CSR), with Keychain App on your Mac or using the commandline.

a. Using Keychain on your Mac

  1. Open the Keychain App
  2. Choose from the menu: Keychain > Certificate assistent > Request certificate from certificate authority…
  3. Fill out the e-mail and name you want in the certificate and choose "Save to disk"
  4. Go ahead and save the file somewhere you can find it again

b. Using the commandline

  1. Open the terminal and go to a folder where you can put the certificate files
  2. Generate a new private key and CSR: openssl req -nodes -newkey rsa:2048 -keyout private.plain.key -out certrequest.csr -subj "/emailAddress=email/CN=Name/C=US"
  3. Secure the private key with an passphrase: openssl rsa -in private.plain.key -des3 -out private.key

2. Generate the certificate

Now that you have your CSR head over to the iOS or Mac "Certificates, Identifiers & Profiles" page in the Member Center.

a. For your iOS App

  1. Click "App IDs"
  2. Look up/create the correct App ID, make sure it's an "Explicit App ID"
  3. Under "App Services" check the "Push Notifications" box (when editting you must first click "Settings" to check the box)
  4. When creating a new App ID continue to the next page
  5. Now upload the CSR you just generated by clicking create certificate under the Production and/or Development SSL Certificate
  6. Go through the wizard and generate and download your certificate

Note: After this you must update all provisioning profiles with this App ID before push notifications will work! Edit something in the related profile to trigger regeneration and download the profile again. See also the "Creating and Installing the Provisioning Profile" section.

b. For your Passbook Pass

  1. Click "Pass Type IDs"
  2. Look up the correct Pass Type ID and click "Settings"
  3. Click "Create certificate..."
  4. Click "Continue", upload the CSR you just generated
  5. Click "Generate", wait for the certificate to be generated and then download it!

Note: The certificate to sign your pass with is exactly the same certificate used for push!

Note: To generate a fresh Pass Type ID just follow the on screen instructions and upload the generated CSR during the process.

3. Export certificate to PEM

You now have your certificate, time to convert it to a Notificato compatible format.

a. If you used Keychain for CSR generation

  1. Click the .cer-file so Keychain will import it
  2. Open Keychain and lookup the certificate
  3. Select both the certificate and the private key associated with it
  4. Right click on the selection and choose "Export 2 items…"
  5. Choose "Personal Information Exchange (.p12)" format and save it to disk as "keychainexport.p12"
  6. Convert the .p12-file to .pem format by running: openssl pkcs12 -in keychainexport.p12 -out certificate.pem

Note: This will first ask for the passphrase you encrypted the p12 with while exporting from Keychain, then it will ask for a new passphrase to encrypt the pem-file with.

b. If you used the commandline for CSR generation

  1. Make sure the downloaded .cer-file is in the same folder as the other generated files
  2. Open the terminal and go to the folder the certificate files are in
  3. Convert Apples certificate to PEM format: openssl x509 -inform der -in aps_development.cer -out aps_development.pem
  4. Then add the key and certificate together: cat aps_development.pem private.key > certificate.pem

Now certificate.pem is the certificate file you can use to push messages with, of course it will only work with choosen APNS environment and App/Passbook Pass you generated the certificate for. Now go push something!