Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #
- # Obtaining Apple Push Notification Services certificates:
- #
- # 1) In developer.apple.com go to the App Id, and configure the push
- # certificates. Follow Apple's instructions for creating the signing
- # requests and generating the certificates.
- #
- # 2) Download the certificates and import them into the local keychain.
- #
- # 3) In Keychain Access, find the certificates, open them and export the
- # _private key_ (not the certificate itself) for each certificate.
- #
- # 4) Now you should have the downloaded aps.cer and exported aps.p12
- # files. Run this script on those files to produce the aps.pem file.
- #
- # - Kimmo Kulovesi, 2017-07-21
- set -e -o pipefail
- p12="$1.p12"
- cer="$1.cer"
- if [ ! -r "$p12" -o ! -r "$cer" ]; then
- p12="$1"
- cer="$2"
- basename="$(echo "$p12" | sed 's/\.p12$//')"
- else
- basename="$1"
- fi
- if [ ! -r "$p12" -o ! -r "$cer" ]; then
- echo "Usage: $0 file.p12 file.cer" >&2
- exit 1
- fi
- outfile="$basename.pem"
- echo "Converting $cer..."
- openssl x509 -in "$cer" -inform der -out "$cer.pem"
- echo "Converting $p12..."
- openssl pkcs12 -nocerts -in "$p12" -out "$p12.pem"
- echo "Decrypting..."
- openssl rsa -in "$p12.pem" -out "$p12.raw.pem"
- echo "Combining..."
- cat "$cer.pem" "$p12.raw.pem" >"$outfile"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement