How to generate PEM for Push Notifications?

Generating PEM files for Push Notifications is very simple. First of all, you have to make an App ID for your application. After that, you can enable and configure the Push Notification service.

Generate PEM for Push Notifications step by step

Step 1

When you click the Create Certificate button, you will see a description of how to generate a Certificate Signing Request using the Certificate Assistant in Keychain Access.

Step 2

Once that’s done, you select Certificate Signing Request and click the ‘generate’ button. This will generate a Push Notification certificate for your app.

Step 3

If everything is okay, you will see a page from which you can download your certificate.

Step 4

Now you can download your certificate and double click on it. The certificate will be added to your Keychain Access.

You can right click on it and export .cer and .p12 files.

Step 5

Now you can combine the .cer and .p12 files into a PEM file using terminal commands.

openssl pkcs12 -nocerts -out Key.pem -in key.key  
cat Cert.pem Key.pem > PEM.pem

I prepared a small script for myself:

rm Cert.pem  
rm Key.pem
rm PEM.pem
openssl x509 -in $1 -inform der -out Cert.pem
openssl pkcs12 -nocerts -out Key.pem -in $2
cat Cert.pem Key.pem > PEM.pem
rm Cert.pem
rm Key.pem

It makes generating a PEM really simple. Just call ./script_name cer.cer key.p12 and that’s it. Now you can use it to send Push Notifications.

➡️Check our Privacy Policy⬅️

Read more from Untitled Kingdom:

--

--