A Blog Of Random Coding Techniques & Experiments Robert Askam

How to Create a PEM File for Push Notifications for your Website Post How to Create a PEM File for Push Notifications for your Website 9 months ago

How to Create a PEM File for Push Notifications for your Website



  • Login into the iOS Developer Console go to Apple Developer and click Account at the top.

  • Click "Certificates, Identifiers & Profiles.

  • Under the Identifiers tab on the left, click App IDs.

  • Click on the App ID for your app.

  • Scroll down and click 'Edit'.

  • Under Production SSL Certificate, click on the "Create Certificate" button.

  • Click the Continue Button.

  • Click on the "Choose File" button and select the Certificate Signing Request file you have on your machine, then click on "Generate." (Shown Below if you haven't got this)

  • Click "Download" to download your new certificate and then click on "Done."

  • Double-click the ".cer" file to install it in Keychain Access.

  • Move to Create a PEM File


Create a PEM File


How to convert a .P12 certificate and key file into a .PEM push notification certificate for deployment



  • Go to your Key Chain and under Category on the Left, Click "My Certificates".

  • Expand the certificate using the arrow on the left of it.

  • Export certificate and private key separately.

  • Select a name test-cert.p12 and choose .p12 as format.

  • When prompted for a password, leave it blank. You may be prompted for the system password.

  • Do this for the private key and name it test-key.p12

  • Open up terminal and type the following in the directory of your certificate to convert .p12 to .pem.

  • openssl pkcs12 -clcerts -nokeys -out test-cert.pem -in test-cert.p12

  • *When prompted for a password, simply press enter since no password should have been given.

  • Now use this command for the Key File.

  • openssl pkcs12 -nocerts -out test-key.pem -in test-key.p12

  • When prompted for a password, simply press enter since no password should have been given. When prompted to "Enter PEM pass phrase", enter pass phrase of your choice.

  • In the same directory remove the encryption of the key file using this command.

  • openssl rsa -in test-key.pem -out test-key-noenc.pem

  • *This will ask you for the pass phrase you entered in "Enter PEM pass phrase"

  • Merge the Certificates using this command.

  • cat test-cert.pem test-key-noenc.pem > test-prod.pem

  • Put on your Server then link your file using.


stream_context_set_option($ctx, 'ssl', 'local_cert', '/test-prod.pem');
stream_context_set_option($ctx, 'ssl', 'passphrase', 'Enter PEM pass phrase');

How to Create a CSR (Certificate Signing Request) File



  • On your Mac, go to the folder 'Applications' → 'Utilities' and open 'Keychain Access.'

  • Go to 'Keychain Access' → Certificate Assistant → Request a Certificate from a Certificate Authority. 

  • Click 'Saved to disk' then fill out the email address to identify with this certificate and in the Common Name field, enter your name, click "Continue."

  • Save the file to your hard drive.