Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # Obtaining Apple Push Notification Services certificates:
  4. #
  5. # 1) In developer.apple.com go to the App Id, and configure the push
  6. # certificates. Follow Apple's instructions for creating the signing
  7. # requests and generating the certificates.
  8. #
  9. # 2) Download the certificates and import them into the local keychain.
  10. #
  11. # 3) In Keychain Access, find the certificates, open them and export the
  12. # _private key_ (not the certificate itself) for each certificate.
  13. #
  14. # 4) Now you should have the downloaded aps.cer and exported aps.p12
  15. # files. Run this script on those files to produce the aps.pem file.
  16. #
  17. # - Kimmo Kulovesi, 2017-07-21
  18.  
  19. set -e -o pipefail
  20.  
  21. p12="$1.p12"
  22. cer="$1.cer"
  23.  
  24. if [ ! -r "$p12" -o ! -r "$cer" ]; then
  25. p12="$1"
  26. cer="$2"
  27. basename="$(echo "$p12" | sed 's/\.p12$//')"
  28. else
  29. basename="$1"
  30. fi
  31.  
  32. if [ ! -r "$p12" -o ! -r "$cer" ]; then
  33. echo "Usage: $0 file.p12 file.cer" >&2
  34. exit 1
  35. fi
  36.  
  37. outfile="$basename.pem"
  38.  
  39. echo "Converting $cer..."
  40. openssl x509 -in "$cer" -inform der -out "$cer.pem"
  41.  
  42. echo "Converting $p12..."
  43. openssl pkcs12 -nocerts -in "$p12" -out "$p12.pem"
  44.  
  45. echo "Decrypting..."
  46. openssl rsa -in "$p12.pem" -out "$p12.raw.pem"
  47.  
  48. echo "Combining..."
  49. cat "$cer.pem" "$p12.raw.pem" >"$outfile"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement