How to create a .pem certificate for sending push notifications
When building an app, you'll probably want to be able to send your users push notifications.
Push notifications are an excellent way to keep your users coming back to use your app. So long as they're not sent too often and they're relevant to your user they're a great tool to have in your box.
Here's the process for creating the .pem file.
First, you'll want to create a certificate and you'll want to save these to your keychain. You might want to create a seperate one for development purposes.
Open Spotlight Search by pressing ⌘ + Space
Search for "Keychain Access"
In step 1, you should've saved these certificates to your keychain. So find them and select the certificate as well as the private key (you want to export them both together). Right-click and select "Export 2 items..."
Enter a name to save the file as and ensure the file format is p12.
Enter a password to lock your certificate. Any time you want to send a push notification with this certificate, you'll require the password. Note: Without a password, anyone can send push notifications to your customers with this certificate. Keep is secret, keep it safe.
Finally, to export a certificate/private key from Keychain Access, you need to enter your password (you might have to do this twice, once for the certificate, once for the private key).
Once you've saved it, open your Terminal with ⌘ + Space and search for "Terminal". Navigate to your wherever you saved your certificate using the cd command. By default they save in Documents, so I did this.
Then, finally, you'll want to covert your .p12 into a .pem file with the following command.
openssl pkcs12 -in YourFile.p12 -out YourNewFile.pem
You'll be prompted to enter the password you used to lock the certificate. You'll also be asked for a PEM password. Create one, and confirm it.
Voila! You have you .pem for sending push notifications.