Last active
August 29, 2015 14:03
-
-
Save pedro380085/ad047a838219cf23cd50 to your computer and use it in GitHub Desktop.
APNS Certificate (Generating, Validating, Sending)
This file contains 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
#!/bin/bash | |
# Two files are neeed to generate and upload your certificate | |
# Development: | |
# - aps_development.cer | |
# - Certificados.p12 | |
# | |
# Production: | |
# - aps_production.cer | |
# - Certificados.p12 | |
# | |
if [[ "$#" -ne 2 ]]; then | |
echo "Usage: $0 MODE(development|production) DIRECTORY_TO_BE_CREATED" >&2 | |
exit 1 | |
fi | |
# Move to download directory | |
cd /Users/pedro/Downloads/ | |
# Generate certificates | |
if [ "$1" = "development" ]; then | |
openssl x509 -in aps_development.cer -inform der -out cert.pem | |
fi | |
if [ "$1" = "production" ]; then | |
openssl x509 -in aps_production.cer -inform der -out cert.pem | |
fi | |
openssl pkcs12 -nocerts -out key.pem -in Certificados.p12 | |
# Test them out | |
if [ "$1" = "development" ]; then | |
openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert cert.pem -key key.pem < /dev/null | |
fi | |
if [ "$1" = "production" ]; then | |
openssl s_client -connect gateway.push.apple.com:2195 -cert cert.pem -key key.pem < /dev/null | |
fi | |
# Move them around | |
mkdir $2 | |
mkdir $2/production | |
mv cert.pem $2/production/ | |
mv key.pem $2/production/ | |
mv $2 /Users/pedro/Trilha-Magic/apns/ | |
# Send them to our server | |
if [ "$2" != "" ]; then | |
sudo scp -r /Users/pedro/Trilha-Magic/apns/$2/ [email protected]:/etc/ssl/apns/ | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment