Skip to content

Instantly share code, notes, and snippets.

@PJayRushton
Last active February 24, 2023 21:41
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 PJayRushton/9d1f338f4c2c199f4cf92ea8c3475e13 to your computer and use it in GitHub Desktop.
Save PJayRushton/9d1f338f4c2c199f4cf92ea8c3475e13 to your computer and use it in GitHub Desktop.
Updating an APNS Credential about to expire in Twilio

Updating Push Certs to Twilio

  1. First of all, Twilio has a great reference here
  2. And the SO article here is also a greate reference

My Version:

Generate a certificate

  1. Go to Apple Dev certs here
  2. Identifiers -> Find identifier in question
  3. Find the correct identifier (prod or stage)
  4. Push Notification capabiity
  5. Configure certificates
  6. Upload certSigningRequest
  7. Download .cert file, click on it to add to keychain

Generate p12 from cert

  1. Open terminal, navigate to directory that :point-up is saved
  2. Export cert as a p12 file

Export as .pem files

  1. Run this command to generate the cert.pem from the .p12 file:
  2. I'll assume your p12 file is name cred_prod.p12. If yours is named something else make sure to swap that out in these commands

openssl pkcs12 -clcerts -nokeys -out cert_prod.pem -in cred_prod.p12

  1. Then run this command to generate the Key.pem from the .p12 file:

openssl pkcs12 -in cred_prod.p12 -nocerts -out key_prod.pem -nodes

  1. Run this command to remove the encoding of the private key:

openssl rsa -in key_prod.pem -out key_prod_noenc.pem

  1. Run this command to verify everything worked

openssl s_client -connect gateway.push.apple.com:2195 -cert cert_prod.pem -key key_prod_noenc.pem

for sandbox push certificates:

openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert cert_dev.pem -key key_dev_noenc.pem

  1. Open the cert_prod.pem file in your favorite text editor.
  2. Copy everything between and including the -----BEGIN CERTIFICATE----- and -----END CERTIFICATE----- for later use
  3. Open the key_prod_noenc.pem file in your favorite text editor
  4. Copy everything between and including: -----BEGIN RSA PRIVATE KEY----- and -----END RSA PRIVATE KEY-----
  5. Go to the Twilio console here
  6. Update or create a new credential.
  7. Paste in the text of both the crediential and private key
  8. Save the Credential.
  9. Celebrate 🎉
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment