How to generate .pem file to set up Apple Push Notifications?

Follow the below steps to generate your .pem file:

Step 1: Log in to your Apple Developer account and click Certificates under Program resources.



Step 2: Click the + icon next to Certificates.
 


 

Step 3: Under Services, select the “Apple Push Notification service SSL (Sandbox & Production)” option, and click Continue.



Step 4: Select the App ID from the dropdown, then click Continue.


 

Step 5:  Upload the Certificate Signing Request, then click Continue.

Note: To obtain the Certificate Signing Request, refer to the tutorial.
 

Step 6: Click Download to download the certificate (.cer).


Step 7: Go to your Downloads in Mac, locate the .cer file, and open it with the Keychain Access (default) option.


Step 8: Under the Certificates tab in the Keychain Access, look for the certificate you have just installed. If unsure which certificate is the correct one, it should start with "Apple Push Services:" followed by your app's bundle ID.


Step 9: Click on the certificate and select the Export “Apple Push Service” option.



Step 10: Save the p12 file to your desktop.
 

Note: Once you’ve saved the file, you will be prompted to enter a password to protect it, you can either provide a password or skip setting the password. 



Step 11: Open "Terminal" on your Mac, and run the following commands:


cd

cd Desktop
openssl pkcs12 -in pushcert.p12 -out pushcert.pem -nodes -clcerts

Note: Above command won't work in M1 and newer devices for that add extra flag -legacy. E.g.

openssl pkcs12 -in Certificates.p12 -out pushcert.pem -nodes -clcerts -legacy




 


Step 12: Once the command is executed successfully, the pushcart.pem file will be generated on your desktop.

 




 

 

Was this article helpful