Generate pem file on Mac for push

Recording the following content is mainly used for a long time, and you will forget it, and you have to check again.


1. Start Keychain-->login keychain-->Certificates category on Mac. You will see development, release, and push certificates. "Apple Development Push Services" is the prefix of the push certificate. After the certificate is expanded, it is the secret key.

2. Expand this option and right-click "Apple Development Push Services"> Export "Apple Development Push Services: App ID". Save it as apns-cert.p12 file.

3. Extend "Apple Development Push Services" and do the same with "Private Key" and save it as apns-key.p12 file.

4. Open the terminal and convert the p12 file to PEM format:

openssl pkcs12 -clcerts -nokeys -out apns-cert.pem -in apns-cert.p12
openssl pkcs12 -nocerts -out apns-key.pem -in apns-key.p12

5. You need to remove the password, do not export/convert Set or execute:
openssl rsa -in apns-key.pem -out apns-key-noenc.pem

6. Combine the certificate and key, and use ssl to connect to apns:
cat apns-cert.pem apns-key-noenc .pem> apns-dev.pem


or:

1.

openssl pkcs12 -clcerts -nokeys -out apns-cert.pem -in apns-cert.p12

// Do not encrypt, remove -nodes if you want to encrypt

openssl pkcs12 -nocerts -out apns-key.pem -in apns-key.p12 -nodes

2. Merge

cat apns-cert.pem apns-key.pem> apns-dev.pem

Under window:

copy / b apns-cert.pem + apns-key.pem apns-dev.pem

Guess you like

Origin blog.csdn.net/wangshengfeng1986211/article/details/38366547
Recommended