Welcome to part 2 of the tutorial on how to create a PEM file for iOS push notifications. You can read the Part 1 here
Step 3. Create .p12 file from digital certificate
(1) Double-click the downloaded aps_development.cer file. You will be presented with Keychain/ Certificate tab dashboard, in which your downloaded certificate file was newly added. Right-click that file and choose Export 2 items.
– Name and save the .p12 file to a folder.
– Then, there will be a popup shown asking for password. Set your own password.
– Click OK. Tada! You’ve created PushChatKey.p12 file from aps_distribution.cer file
So now you got three files
- The CSR
- The private key as a p12 file (PushChatKey.p12)
- The SSL certificate, aps_ distribution.cer
Let’s move to last step
Step 4. Create PEM file
Store these three files in a safe place. Then you have to convert the SSL 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.
You’re going to use the command-line OpenSSL tools for this. Open a Terminal and execute the following steps.
Go to the folder where you downloaded the files, in this case is the Desktop:
$ cd ~/Desktop/
Convert the .cer file into a .pem file:
$ openssl x509 -in aps_distribution.cer -inform der -out PushChatCert.pem
Convert the private key’s .p12 file into a .pem file:
$ openssl pkcs12 -nocerts -out PushChatKey.pem -in PushChatKey.p12 Enter Import Password: MAC verified OK Enter PEM pass phrase: Verifying – Enter PEM pass phrase:
You first need to enter the passphrase for the .p12 file so that Open SSL can read it. Then you need to enter a new passphrase that will be used to encrypt the PEM file. Again for this tutorial I used “pushchat” as the PEM passphrase. You should choose something more secure.
Notice: if you don’t enter a PEM passphrase, Open SSL will not give an error message but the generated .pem file will not have the private key in it.
Finally, combine the certificate and key into a single .pem file:
$ cat PushChatCert.pem PushChatKey.pem > ck.pem
Yay, now you get the PEM file, which can be then used to set up Push notification feature on the iOS application. Do you find this easy to follow? If you get any problem, feel free to comment in the box below, I will reply soon!
P/s: If you are customers of SimiCart, please upload this PEM file to your Magento backend to enable the Push notification for your application.