Skip to content

Instantly share code, notes, and snippets.

@vinod1988
Last active December 19, 2019 12:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vinod1988/d0ec67618abb57dec3147fd8c7f0b323 to your computer and use it in GitHub Desktop.
Save vinod1988/d0ec67618abb57dec3147fd8c7f0b323 to your computer and use it in GitHub Desktop.
Create p12 to PEM for iOS Push Notification
Creating .pem file for APNS?
Development Phase:
Step 1: Create Certificate .pem from Certificate .p12
Command: openssl pkcs12 -clcerts -nokeys -out apns-dev-cert.pem -in apns-dev-cert.p12
Step 2: Create Key .pem from Key .p12
Command : openssl pkcs12 -nocerts -out apns-dev-key.pem -in apns-dev-key.p12
Step 3: Optional (If you want to remove pass phrase asked in second step)
Command : openssl rsa -in apns-dev-key.pem -out apns-dev-key-noenc.pem
Step 4: Now we have to merge the Key .pem and Certificate .pem to get Development .pem needed for Push Notifications in Development Phase of App
Command : cat apns-dev-cert.pem apns-dev-key-noenc.pem > apns-dev.pem (If 3rd step is performed )
Command : cat apns-dev-cert.pem apns-dev-key.pem > apns-dev.pem (if not)
Step 5: Check certificate validity and connectivity to APNS
Command: openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert apns-dev-cert.pem -key apns-dev-key.pem (If 3rd step is not performed )
Command: openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert apns-dev-cert.pem -key apns-dev-key-noenc.pem (If performed )
Production Phase:
Step 1: Create Certificate .pem from Certificate .p12
Command: openssl pkcs12 -clcerts -nokeys -out apns-pro-cert.pem -in apns-pro-cert.p12
Step 2: Create Key .pem from Key .p12
Command : openssl pkcs12 -nocerts -out apns-pro-key.pem -in apns-pro-key.p12
Note: Enter pass phrase : vinod (This is mandatory)
Step 3: Optional (If you want to remove pass phrase asked in second step)
Command : openssl rsa -in apns-pro-key.pem -out apns-pro-key-noenc.pem
Step 4: Now we have to merge the Key .pem and Certificate .pem to get Production .pem needed for Push Notifications in Production Phase of App
Command : cat apns-pro-cert.pem apns-pro-key-noenc.pem > apns-pro.pem (If 3rd step is performed ) Command : cat apns-pro-cert.pem apns-pro-key.pem > apns-pro.pem (if not)
Step 5: Check certificate validity and connectivity to APNS
Command: openssl s_client -connect gateway.push.apple.com:2195 -cert apns-pro-cert.pem -key apns-pro-key.pem (If 3rd step is not performed )
Command: openssl s_client -connect gateway.push.apple.com:2195 -cert apns-pro-cert.pem -key apns-pro-key-noenc.pem (If performed )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment