Created
January 5, 2016 05:11
-
-
Save blacklee/4fc8822c3e3b8e5c2632 to your computer and use it in GitHub Desktop.
APNS pem file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set -e | |
set -x | |
input=$1 | |
output=$2 | |
input_cert=$(echo $input)-cert.p12 | |
input_key=$(echo $input)-key.p12 | |
input_file_not_exists=0 | |
if [[ ! -f $input_cert ]]; then | |
echo "$input_cert not exist" | |
input_file_not_exists=1 | |
fi | |
if [[ ! -f $input_key ]]; then | |
echo "$input_key not exist" | |
input_file_not_exists=1 | |
fi | |
if [[ $input_file_not_exists -eq 1 ]]; then | |
echo "you should prepare 2 files: $input_key and $input_cert" | |
exit 1 | |
fi | |
if [[ $output == "" ]]; then | |
echo "you may specify the output file name" | |
exit 1 | |
fi | |
openssl pkcs12 -clcerts -nokeys -in apns-cert.p12 -out apns-cert.pem | |
openssl pkcs12 -nocerts -in apns-key.p12 -out apns-key.pem | |
openssl rsa -in apns-key.pem -out apns-key-noenc.pem | |
cat apns-cert.pem apns-key-noenc.pem > $(echo $output).pem | |
rm apns-cert.pem | |
rm apns-key-noenc.pem | |
rm apns-key.pem |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
openssl rsa -in apns-dev-key.pem -out apns-dev-key-noenc.pem
cat apns-dev-cert.pem apns-dev-key-noenc.pem > apns-dev.pem