Skip to content

Instantly share code, notes, and snippets.

@rudyryk
Created August 26, 2013 06:34
Show Gist options
  • Save rudyryk/6338583 to your computer and use it in GitHub Desktop.
Save rudyryk/6338583 to your computer and use it in GitHub Desktop.
Helper script for generating push notification certificates based on tutorial: http://www.raywenderlich.com/32960/apple-push-notification-services-in-ios-6-tutorial-part-1
#!/bin/sh
# Helper script for generating push notification certificates based on tutorial:
# http://www.raywenderlich.com/32960/apple-push-notification-services-in-ios-6-tutorial-part-1
function show_help_and_exit
{
echo "usage:" $0 \<certificate output\> \<private key output\> \<combined output\>
echo
echo "Input files are not specified, they are supposed to have"
echo "standard names: aps_development.cer and Certificates.p12."
echo
echo " example:" $0 MyCertificate.pem MyPrivateKey.pem MyCombined.pem
echo
exit
}
if [ "$1" != "" ]; then
openssl x509 -in aps_development.cer -inform der -out $1
else
show_help_and_exit
fi
if [ "$2" != "" ]; then
openssl pkcs12 -nocerts -out $2 -in Certificates.p12
else
show_help_and_exit
fi
if [ "$3" != "" ]; then
cat $1 $2 > $3
else
show_help_and_exit
fi
echo "Now test connection with command:"
echo
echo " openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert $1 -key $2"
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment