alexryasn / javapns

Automatically exported from code.google.com/p/javapns
0 stars 0 forks source link

getting javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure #147

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Created certificates from mac machine
2. in tomcat server application using JavaPNS to send the notification
Used Push.alert(...) used .p12 file

As per the mentioned documents I have installed the .cer doenloaded from 
developer.apple and generated .pem file intstalled on windows server

Used latest 2.2 version

2012-09-28 21:03:38,466 INFO  
javapns.notification.PushNotificationManager.sendNotification:433 - Attempt 
failed (Received fatal alert: handshake_failure)... trying again
44249 [Thread-36] INFO javapns.notification.PushNotificationManager  - Attempt 
failed (Received fatal alert: handshake_failure)... trying again
2012-09-28 21:03:39,265 INFO  
javapns.notification.PushNotificationManager.sendNotification:433 - Attempt 
failed (Received fatal alert: handshake_failure)... trying again
45048 [Thread-36] INFO javapns.notification.PushNotificationManager  - Attempt 
failed (Received fatal alert: handshake_failure)... trying again
2012-09-28 21:03:40,001 ERROR 
javapns.notification.PushNotificationManager.sendNotification:426 - Attempt to 
send Notification failed and beyond the maximum number of attempts
itted
45784 [Thread-36] ERROR javapns.notification.PushNotificationManager  - Attempt 
to send Notification failed and beyond the maximum number of attempts permitted
2012-09-28 21:03:40,005 ERROR 
javapns.notification.PushNotificationManager.sendNotification:429 - Delivery 
error
javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
        at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:174)
        at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:136)
        at com.sun.net.ssl.internal.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:1806)
        at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:986)
        at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1170)
        at com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:637)
        at com.sun.net.ssl.internal.ssl.AppOutputStream.write(AppOutputStream.java:89)
        at java.io.OutputStream.write(OutputStream.java:58)
        at javapns.notification.PushNotificationManager.sendNotification(PushNotificationManager.java:402)
        at javapns.notification.PushNotificationManager.sendNotification(PushNotificationManager.java:350)
        at javapns.notification.PushNotificationManager.sendNotification(PushNotificationManager.java:320)
        at javapns.Push.sendPayload(Push.java:177)
        at javapns.Push.alert(Push.java:47)
        at com.disco.api.service.PushNotificationServiceImpl.test(PushNotificationServiceImpl.java:44)
        at com.disco.api.action.ViewUserAction$1.run(ViewUserAction.java:28)
45788 [Thread-36] ERROR javapns.notification.PushNotificationManager  - 
Delivery error
javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
        at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:174)
        at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:136)
        at com.sun.net.ssl.internal.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:1806)
        at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:986)
        at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1170)
        at com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:637)
        at com.sun.net.ssl.internal.ssl.AppOutputStream.write(AppOutputStream.java:89)
        at java.io.OutputStream.write(OutputStream.java:58)
        at javapns.notification.PushNotificationManager.sendNotification(PushNotificationManager.java:402)
        at javapns.notification.PushNotificationManager.sendNotification(PushNotificationManager.java:350)
        at javapns.notification.PushNotificationManager.sendNotification(PushNotificationManager.java:320)
        at javapns.Push.sendPayload(Push.java:177)
        at javapns.Push.alert(Push.java:47)
        at com.disco.api.service.PushNotificationServiceImpl.test(PushNotificationServiceImpl.java:44)
        at com.disco.api.action.ViewUserAction$1.run(ViewUserAction.java:28)
2012-09-28 21:03:40,011 ERROR 
javapns.notification.PushNotificationManager.sendNotification:450 - Delivery 
error: javax.net.ssl.SSLHandshakeException: Received fatal alert: ha
ke_failure
45794 [Thread-36] ERROR javapns.notification.PushNotificationManager  - 
Delivery error: javax.net.ssl.SSLHandshakeException: Received fatal alert: 
handshake_failure

Original issue reported on code.google.com by mahendr...@gmail.com on 28 Sep 2012 at 5:12

GoogleCodeExporter commented 9 years ago
Is there a proxy or a firewall in front of your server that could be 
interfering with the connection?

What happens if you run JavaPNS from the command line?

Could you please provide the full log output from JavaPNS, not just the 
exceptions part?

Could you also try version 2.3 Beta, which is in the trunk?

Thank you!

Original comment by sype...@gmail.com on 28 Sep 2012 at 5:38

GoogleCodeExporter commented 9 years ago
I am a new iOS developer and have the same issue before. And this may be the 
same issue you facing.

I finally find the problem is 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.

Original comment by fongyat...@gmail.com on 30 Sep 2012 at 7:34

GoogleCodeExporter commented 9 years ago
yes you are correct I was doing same mistake. I have corrected the .p12 file 
and its working fine.
Thanks

Original comment by mahendr...@gmail.com on 4 Oct 2012 at 7:11

GoogleCodeExporter commented 9 years ago
Closing issue report.  Thank you.

Original comment by sype...@gmail.com on 5 Oct 2012 at 2:52