Invalid token when using Apple Push Notifications (APN) for Passbook

Found the root cause for this issue, it is because of bad private key. To resolve this issue just generate a .p12 certificate with .pem . For creating the p12 file with .pem file please follow the below method

Steps


If you are using a pruduction certificate to connect to the APN production server, you must use a production token.

The fact that you get "invalid token" when sending the notification to the sandbox server means you are using a production token, which works only with the production server.

The fact that sending the token to the production server returns the token in the feedback service means that the application that matches the certificate (which your server is using to send the notification) is either uninstalled from the device or has push notifications disabled. Perhaps you are using a wrong certificate (perhaps a certificate that belong to a different App that was uninstalled from the device).


Rewriting the above statements in text format so you can copy/paste them. That did the trick for me, PushSharp 4.0.10 was returning an error about an invalid certificate, but executing these commands on the original public and private keys solve the problem:

openssl x509 -in aps.cer -inform DER -out aps.pem -outform PEM
openssl pkcs12 -nocerts -in mykey.p12 -out mykey.pem
openssl pkcs12 -export -inkey mykey.pem -in aps.pem -out iphone.p12

For Passbook pushes, you need to be connecting to the production server with the Pass Type ID certificate, not the App certificate.

All Passbook pushes go through the production server, there is no way to use the sandbox.

Also, the push payload should be empty for a Passbook push. Anything you do send will be ignored.