Introduction to .pem file:In this tutorial we will learn how to create / generate .pem file for Apple push notification in iOS.Pem file are placed on the server that connects with Apple Push server in order to send push to our iOS app.
Steps to create .pem file for Push Notification:Step 1: Login with your developer account on Apple developer website
Step 2: Click on certificates, identifiers and profiles as shown in given below image/screenshot
Step 3: Click + icon/button in order to start generating push certificate
Step 4: Select Apple push certificate as per your requirement, we have two types of push certificates
1) Apple push Service SSL (Sandbox) - used to send push notification during app development phase
2) Apple push Service SSL (Sandbox & production) - used to send push notification when app goes live on app store
Step 5: We selected Apple Push Notification SSL listed under Development tab for this tutorial, After selection press continue button at the bottom of the page.
Step 6: Select app id for which you want to configure Push Notifications and press continue button
Select 7: Generate CSR (certificate Signing Request) as described by Apple. If you already have one press continue and upload it by clicking on Choose file button. Press continue to move to next step.
Step 8: You will see your apple development push service certificate. Download it and press done.
Step 9: Locate the downloaded certificate in the finder and double click in order to install it in your mac machine. It will open another application called "Keychain Access". Now go to “Keychain” on you mac system, look for the certificate you have just installed. If you are unsure which certificate is the correct , it should start with “Apple Production IOS Push Services”and followed by app’s bundleID.
Step 10: Expand the certificate, you should see the private key with either your name or your company name. Select both items by using the “Select” key on your keyboard, right click (or cmd-click if you use a single button mouse), choose “Export 2 items”. It will save as .p12 file.
Step 11: Save them with name "pushcert". System will prompt you to secure the exported item with password, enter password (if you don't want to enter any password then leave it blank). In next step system will ask you to enter your system password in order to complete export.
Step 12: Open terminal and locate to place where you save .p12 files. (in our case its Desktop). Type below command in terminal
openssl pkcs12 pushcert.p12 out pushcert.pem nodes clcerts
We are done with the tutorial, we successfully generated .pem file. If you have any questions please feel
free to comment.