Tuesday, August 6, 2013

iOS- Create push notification private key by shell script

To use the push notification, you need to create a  p12 private key file to your server side. I would like to create a shell script for it. Then you can reuse it for some time.

First of all, you need to three source file :1.certSigningRequest, 2.p12(private key for the certificate), 3.cer(provision profile)

for example, using .Net to send push notification, you need to create a p12 file, you need to type 3 lines of command, which is

then you need to type the followinig command as below:

openssl x509 -in 3.cer -inform der -out PushCert.pem

openssl pkcs12 -nocerts -out PushKey.pem -in 2.p12


openssl pkcs12 -export -in PushCert.pem -inkey PushKey.pem -certfile 1.certSigningRequest -name "apn_production_identity" -out apn_production_identity.p12

Step one:
Open your terminal, type vim my_script

Step two:
input the following words:

#!/bin/bash
# Create push p12 file

openssl x509 -in 3.cer -inform der -out PushCert.pem

openssl pkcs12 -nocerts -out PushKey.pem -in 2.p12

openssl pkcs12 -export -in PushCert.pem -inkey PushKey.pem -certfile 1.certSigningRequest -name "apn_production_identity" -out apn_production_identity.p12



Step three:
save the file and put the source files and my_script in the same folder

Step four:
Open terminal, cd to the folder, run
bash my_script

After enter the password to verify, then you will get the p12 file, which is apn_production_identity.p12







No comments:

Post a Comment