Making a PEM File
You have three files for the making pem file:- The CSR
- The private key as a p12 file (devKey.p12)
- The SSL certificate, aps_development.cer
You have to convert the certificate and private key into a format
that is more usable. Because the push part of our server will be written
in PHP, you will combine the certificate and the private key into a
single file that uses the PEM format.
The specifics of what PEM is doesn’t really matter (in fact, I have
no idea) but it makes it easier for PHP to use the certificate. If you
write your push server in another language, these following steps may
not apply to you.
You’re going to use the command-line OpenSSL tools for this. Open a Terminal and execute the following steps.
Generating the Apple Push Notification SSL certificate on Mac:
Payload Contents
The payload is formatted in JSON, compliant with the RFC 4627 standard. It consists of several parts:
- Log in to the iPhone Developer Connection Portal and click App IDs
- Ensure you have created an App ID without a wildcard. Wildcard IDs
cannot use the push notification service. For example, our iPhone
application ID looks something like
AB123346CD.com.serverdensity.iphone - Click Configure next to your App ID and then click the button to generate a Push Notification certificate. A wizard will appear guiding you through the steps to generate a signing authority and then upload it to the portal, then download the newly generated certificate. This step is also covered in the Apple documentation.
- Import your
aps_developer_identity.cerinto your Keychain by double clicking the.cerfile. - Launch Keychain Assistant from your local Mac and from the login keychain, filter by the Certificates category. You will see an expandable option called “Apple Development Push Services”
- Expand this option then right click on “Apple Development Push Services” > Export “Apple Development Push Services ID123″. Save this as apns-dev-cert.p12 file somewhere you can access it.
- Do the same again for the “Private Key” that was revealed when you expanded “Apple Development Push Services” ensuring you save it as apns-dev-key.p12 file.
- These files now need to be converted to the PEM format by executing this command from the terminal:
openssl pkcs12 -clcerts -nokeys -out apns-dev-cert.pem -in apns-dev-cert.p12 openssl pkcs12 -nocerts -out apns-dev-key.pem -in apns-dev-key.p12 - If you wish to remove the passphrase, either do not set one when exporting/converting or execute:
openssl rsa -in apns-dev-key.pem -out apns-dev-key-noenc.pem - Finally, you need to combine the key and cert files into a apns-dev.pem file we will use when connecting to APNS:
cat apns-dev-cert.pem apns-dev-key-noenc.pem > apns-dev.pem
Payload Contents
The payload is formatted in JSON, compliant with the RFC 4627 standard. It consists of several parts:
- Alert – the text string to display on the device
- Badge – the integer number to display as a badge by the application icon on the device home screen
- Sound – the text string of the name of the sound to accompany the display of the message on the device
- This tutorial will only deal with the basics by sending a simple alert text string but this can also be another dictionary containing various options to display custom buttons and the like.
Steps for making a PEM File
Distribution Steps for Create the pem file….
1. export the development/distribution certificate in p12 file.
2. export the key file with your name in p12 file.
now open your Terminal window.
Go to the folder where you downloaded the files, in my case the Desktop:
$ cd ~/Desktop/openssl pkcs12 -clcerts -nokeys -out apns-production.pem -in aps_production.p12
3. then….
openssl pkcs12 -nocerts -out apns-production-key.pem -in aps_production_key.p12
4. then enter the parse password
then created two pem file one for key pem and pem
now remove the parse phase of key pem
openssl rsa -in apns-production-key.pem -out apns-production-key-noenc.pem
5. now remove the password of the parse phase of key pem
and generate the new noecn_pem file
Finally, you need to combine the key and cert files into a apns-production-key.pem file we will use when connecting to APNS:
now combine the first pem and last pem into one pem file…
cat apns-production.pem apns-production-key-noenc.pem > apns-prod-distubution.pem
Development Steps for Create the pem file….
1. export the development/distribution certificate in p12 file.
2. And export the private key file with your name in p12 file.
now open your Terminal window.
Go to the folder where you downloaded the files, in my case the Desktop:
$ cd ~/Desktop/openssl pkcs12 -clcerts -nokeys -out apns-dev-cert.pem -in apns-dev-cert.p12
3. then….
openssl pkcs12 -nocerts -out apns-dev-key.pem -in apns-dev-key.p12
4. then enter the parse password
then created two pem file one for key pem and pem
now remove the parse phase of key pem
openssl rsa -in apns-dev-key.pem -out apns-dev-key-noenc.pem
5. now remove the password of the parse phase of key pem
and generate the new noecn_pem file
6. Finally, you need to combine the key and cert files into a apns-dev.pem file we will use when connecting to APNS:
cat apns-dev-cert.pem apns-dev-key-noenc.pem > apns-dev.pem
cat apns-dev-cert.pem apns-dev-key.pem > apns-dev.pem
ReplyDeletehi thanks a lot for sharing such wonderful tutorial. it saved my lot of time .. nice.