Cannot send push notifications using Javapns/Javaapns SSL handshake failure

亡梦爱人 提交于 2019-11-27 06:49:59
Sunny

I am a new iOS developer and I had the same issue before.

I finally found that the problem was due to the p12 certificate. We should not use the private key p12 file, instead we should generate a p12 from your private key and the cert download from Apple.

Please execute the following OpenSSL command to get the correct p12 file:

developer_identity.cer <= download from Apple
mykey.p12 <= Your private key

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

After that, you should use iphone_dev.p12 to communicate with apple server.

Delorean

Sunny's answer is a great one, but unfortunately it didn't work for me.

I got it working by exporting the certificate/private key pair from the keychain. The trick is that the selection sequence matters! The certificate has to be selected first, followed by the private key.

Here is how it works:

  1. Import the certificate downloaded from Apple into the keychains
  2. Expand so that the private key is visible
  3. Select the certificate followed by the private key
  4. Right click and choose [Export 2 items...]
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!