How can I generate pem file for push notifications in iphone?
Asked Answered
T

6

13

Using this link for generate pem file for push notification, but I can't understand following steps...

Installing the SSL Certificate and Key on the Server

You should install the SSL distribution certificate and private cryptographic key you obtained earlier on the server computer on which the provider code runs and from which it connects with the sandbox or production versions of APNs. To do so, complete the following steps:

  1. Open Keychain Access utility and click the My Certificates category in the left pane.

  2. Find the certificate you want to install and disclose its contents. You'll see both a certificate and a private key.

  3. Select both the certificate and key, choose File > Export Items, and export them as a Personal Information Exchange (.p12) file.

  4. Servers implemented in languages such as Ruby and Perl often are better able to deal with certificates in the Personal Information Exchange format. To convert the certificate to this format, complete the following steps:

    • In KeyChain Access, select the certificate and choose File > Export Items. Select the Personal Information Exchange (.p12) option, select a save location, and click Save.

    • Launch the Terminal application and enter the following command after the prompt: openssl pkcs12 -in CertificateName.p12 -out CertificateName.pem -nodes.

  5. Copy the .pem certificate to the new computer and install it in the appropriate place.

Typewriter answered 17/4, 2013 at 8:57 Comment(1)
which two certificate are seleceted in step 3 ?Typewriter
T
12

finally i sloved generate push notification certifcates

complete step for generate push notification certificates.....

1) open key chain and request certificate show in below image.

enter image description here

2) change common name as your project_name.

enter image description here

3) in keychain open key you can show two key public and private

enter image description here

4) write click on private key and export it.

enter image description here

5) make name project_name_key.p12

6) add password ex-1234

7) enter system login password and save it. now you have following certificates.

enter image description here

8) now goto developer account (https://developer.apple.com/devcenter/ios/index.action) and goto identifier create new if not exits. and edit setting.

enter image description here enter image description here

if push notification disable then enable it from edit.

enter image description here

9) for development you can create first one and distribution you can select last one.

enter image description here enter image description here

10) after select and generate download apns certificate and put into desktop and double click on it.

11) then open key chain and goto certificates. and you can show your push service open then you show private key.

export it with 1234 password.

enter image description here

12) now you have following file.

enter image description here

13) open terminal and goto desktop.

enter image description here

14) generate .pem file using following line for push_cert.p12 file

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

then enter password:-1234

enter image description here

15) generate .pem file using following line for project_name_key.p12 file

openssl pkcs12 -nocerts -out apns-dev-key.pem -in project_name_key.p12

then enter password:-1234 Enter PEM pass phrase:1234 Verifying - Enter PEM pass phrase:1234

enter image description here

16) enter following 3 line in terminal

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

Enter pass phrase for apns-dev-key.pem:1234

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

enter image description here

17) you have following certificate.

enter image description here

18) apns-dev.pem file send on server and it pass is 1234

19) for development you must use gateway.sandbox.push.apple.com server. and distribution you can use gateway.push.apple.com server.

Typewriter answered 27/4, 2014 at 4:0 Comment(1)
Sorry but it's not clear to me what does mean 'send .pem file on server'. I'll have to generate push notifications from an Apache server using php. Do I have to put this file in my server directory and reference it from my php code?Ezraezri
C
10

For **

  • Production Push Notification

**

I took reference from this link

To enable Push Notification for your iOS app, you will need to create and upload the Apple Push Notification Certificate (.pem file) to us so we will be able to connect to Apple Push Server on your behalf.

(Updated version with updated screen shots Here http://www.apptuitions.com/generate-pem-file-for-push-notification/)

Step 1: Login to iOS Provisioning Portal, click "Certificates" on the left navigation bar. Then, click "+" button.

enter image description here

enter image description here

enter image description here

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

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.

enter image description here

Step 4: Follow the steps "About Creating a Certificate Signing Request (CSR)" to create a Certificate Signing Request. enter image description here

To supplement the instruction provided by Apple. Here are some of the additional screenshots to assist you to complete the required steps:

Step 4 Supplementary Screenshot 1: Navigate to Certificate Assistant of Keychain Access on your Mac.

enter image description here

Step 4 Supplementary Screenshot 2: Fill in the Certificate Information. Click Continue.

enter image description here

Step 5: Upload the ".certSigningRequest" file which is generated in Step 4, then click "Generate" button. enter image description here

Step 6: Click "Done" to finish the registration, the iOS Provisioning Portal Page will be refreshed that looks like the following screen: enter image description here

Then Click "Download" button to download the certificate (.cer file) you've created just now. - Double click the downloaded file to install the certificate into Keychain Access on your Mac.

Step 7: On your Mac, 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. enter image description here

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", like Below: enter image description here

Then save the p12 file with name "pushcert.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 the most difficult part - open "Terminal" on your Mac, and run the following commands:

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

Step 10: By using this link(click here)

You can check weather the .PEM file is valid or not ---> if it's valid you will get success message with notification like: enter image description here

For **

  • Development Push Notification

**

Just Watch the following Youtube link Click here and enjoy..

Cown answered 6/1, 2016 at 13:14 Comment(1)
In my case, just exporting the certificate (parent of private key) worked. Exporting both certificate and private key did not work.Telmatelo
T
6

Here's a screenshot of what you have to select in step 3. It's not two certificates. It's a certificate + key.

enter image description here

Turban answered 18/4, 2013 at 17:52 Comment(3)
after exporting key and certificate .p12 is genereated how i will generate .pem by using terminalGlucoside
@Glucoside I've never tried it myself, but did you try openssl pkcs12 -in CertificateName.p12 -out CertificateName.pem -nodes?Turban
yes i tried by importing both certificate and key .once i got mypushdev.p12 cerificate then i open terminal and wrote this code openssl pkcs12 -in mypushdev.p12 -out mypushdev.pem -nodes.Glucoside
M
4

I would suggest a much more simple solution. Just use Certifire.
Certifire is a macOS application that generates Apple Push Notification Certificates with just one click in a couple of seconds.

Here are the steps:
1. Download the app.
2. Log in using your Apple Developer Account credentials.
3. Choose the App-ID
4. Click "Generate" button
5. You're done!

You will get APN certificates in .pem format as well as in .p12 format. Even more, you will get also combined .pem and .p12 too (key+cert)!
Much more, you will get no-passphrase versions of all these certificates also!

enter image description here

enter image description here

Mitis answered 29/11, 2017 at 11:49 Comment(1)
This is awesome ! ! !Girish
T
1

Just to add the @Nitin's very well described answer. After creating the pem, you can validate it with the openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert MyKey.pem -key MyKey.pem where MyKey is the name of your pem file.

Replace the gateway.sandbox.push.apple.com with gateway.push.apple.com, to connect to the live APNS.

Telmatelo answered 4/8, 2015 at 10:17 Comment(0)
G
0
  1. Right click on your APNs certificate and click on export. This will generate the .p12 certificate on desktop
  2. open terminal cd desktop and convert .p12 into .pem using following command

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

    as shown in picture

Genarogendarme answered 6/9, 2017 at 11:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.