Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating.pem file for push notification?

Tags:

ios

iphone

ipad

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?

like image 816
hacker Avatar asked Jul 18 '12 07:07

hacker


People also ask

How to create a pem file for iOS push notifications?

Here’s Detailed Guide to Create a .PEM File. Step 1: Generate the Certificate Signing Request (CSR) Step 2: Generate the App ID and SSL Certificate. Step 3. Create .p12 file. Step 4. Generate PEM file. While building a mobile app with SimiCart, many customers encounter difficulties in creating a PEM file for iOS push notifications. ...

How do I verify my PEM file is generated?

Now your .pem file is generated. Verify .pem file First, open the .pem in a text editor to view its content. The certificate content should be in format as shown below. Make sure the pem file contains both Certificate content (from BEGIN CERTIFICATE to END CERTIFICATE) as well as Certificate Private Key (from BEGIN PRIVATE KEY to END PRIVATE KEY) :

How to set up push notifications for iOS apps?

Convert the .cer file into a .pem file: Convert the private key’s .p12 file into a .pem file: Finally, combine the certificate and key into a single .pem file: The file app_pushnotification_end.pem is the one you need, which can be then used to set up push notification feature on your iOS application.

What does the label inside a pem file represent?

The label inside a PEM file represents the type of the data more accurately than the file suffix, since many different types of data can be saved in a “.pem” file. iOS app allows you to push notifications to all of your mobile users. There are three things a push notification can do: PEM file is used to setup Apple Push Notification.


2 Answers

For creation of .pem file you need to follow the below simple steps.

Here you go.

Step 1 : Login to your Developer account go to Provisioning Portal, click "Certificates". Then, click '+' button.

Step 2 : Select Apple Push Notification service SSL (Production) option under Distribution section, then click "Continue".

Step 3 : Select the App ID you want to use for your BYO app (How to Create An App ID), then click "Continue" to go to next step.

Step 4 : Follow the steps "About Creating a Certificate Signing Request (CSR)" for create a Certificate Signing Request.

Step 5 : Upload the ".CSR" file which is generated in Step 4, then click "Generate".

Step 6 : Click "Done" to finish the registration, the iOS Provisioning Portal Page will be change the UI.

Step 7 : Now go to "Keychain", look for the certificate you have just installed. If unsure which certificate is the correct one, it should start with "Apple Production IOS Push Services:" followed by your app's bundle ID.

Step 8 : 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". Then save the p12 file with name "yourselectedname.p12" to your Desktop - now you will be prompted to enter a password to protect it, you can either click Enter to skip the password or enter a password you desire.

Step 9 : Now open "Terminal" on your Mac, and run the following commands:
cd
cd Desktop
openssl pkcs12 -in pushcert.p12 -out pushcert.pem -nodes -clcerts

** DONE you have successfully created an Apple Push Notification Certificate (.pem file)!**

like image 120
Maulik Pandya Avatar answered Oct 14 '22 15:10

Maulik Pandya


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

like image 33
Charan Avatar answered Oct 14 '22 13:10

Charan