hacker hacker - 2 months ago 11x
iOS Question

Creating.pem file for push notification?

I have an IPhone application in which i am implementing push notifications.For that i created a csrfile,p12 file,and production cer.Enabled push notification for the app id.And provision file downloaded.And when i run on the device i got a registering notification came also.But when i combined the pem file from certificate and pem file from p12 key,and generated another pem file and put in my server.The push notifications are not coming in to my phone.I have used this commands on the terminals to create files.`

openssl x509 -in aps_production.cer -inform der -out phoneapp.pem

openssl pkcs12 -nocerts -out phoneappKey.pem -in veapp.p12

cat phoneapp.pem phoneappKey.pem > applicationwebservice.pem

`can anybody help me to get the pem file correctly?


After getting the p12 file, it needs to be converted to the PEM format by executing this command from the terminal:

openssl pkcs12 -clcerts -nokeys -out apns-dev-cert.pem -in apns-dev-cert.p12
openssl pkcs12 -nocerts -out apns-dev-key.pem -in apns-dev-key.p12

If you wish to remove the passphrase, either do not set one when exporting/converting or execute:

openssl rsa -in apns-dev-key.pem -out apns-dev-key-noenc.pem

Finally, you need to combine the key and cert files into a apns-dev.pem file we will use when connecting to APNS:

cat apns-dev-cert.pem apns-dev-key-noenc.pem > apns-dev.pem

This is the way to get the pem file, for more details refer my blog