IOS - How to check if a pem pem file is valid or not?

I created files for creating and producing pem. I have completed the following steps:

1) developer.apple.com: checking the AppIDs section Package ID supports SSL development certificate; if not, create this certificate (which supports APNS)

2) open keychain

3) Right-click on our certificate and export certificate.

4) you will get the .p12 file from here: like: hope_APNS.p12

5) open a console (terminal) and run the following command (use the created .p12 file here) openssl pkcs12 -in apns-dev-cert.p12 -out apns-dev-cert.pem -nodes -clcerts

6) you will get a .pem file for it. (e.g. hope_APNS.pem)

The pem development file is working fine. But there are some in the pem production file. When I install the production pem file and send a push notification from the console. I will not click on my device.

+6
source share
2 answers

This is an old thread, but I was looking for the same answer and hope this solution helps someone ... worked for me.

You can test your PEM key using the following command, which should hang if successful until you press enter:

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

The above PEM Key test in sandbox mode. For production mode, use the following command:

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

Thanks to Craig at https://www.pubnub.com/knowledge-base/discussion/234/how-do-i-test-my-pem-key

+13
source

There are many reasons why you cannot receive push notifications through a production certificate on your device. In addition, to make sure that you have created a separate production certificate correctly, here are a few things to check:

  • An Ad-Hoc or Distribution assembly is installed on your test device when testing a production certificate
  • You have successfully collected a token for the production of the specified device (which will always be different from the push marker of the development file)
  • You can connect to Apple Push Notification PRODUCTION servers (gateway.push.apple.com, port 2195) with a new certificate (i.e. / you can open a socket connection and it does not close immediately)
  • You have verified that your certificate has not expired.

Otherwise, you really need to check what happens at the network level when you send something through this certificate. If it is invalid, it will not connect at all to Apple. If it is valid, but the push token you are sending does not recognize Apple, an error code will be returned (if you use the binary interface) or the connection will be disconnected. You can also look at the APNS feedback API to get a better idea of ​​what is going wrong.

You can check this answer and this other answer for more tips.

0
source

Source: https://habr.com/ru/post/987184/


All Articles