Reputation: 382
I am developing a Push Notification service in Java for apple, and for that i have used JavaPNS 2.2. I have used tutorials available at this site to create my certificates in Apple and run the demo (in PHP), successfully. (I have also converted the certificates in .p12, .pem files).
However when i try to run the simple push notification in java in my test class (As specified in JavaPNS tutorial),
public class PushTest {
public static void main(String[] args) {
try {
List<PushedNotification> notifications = Push.alert("Hello World!", "<filename>.p12", "<password>", true, "<devicetoken>");
System.out.println("List of Device: "+notifications);
List<Device> inactiveDevices = Push.feedback("<filename>.p12", "<password>", true);
} catch (CommunicationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (KeystoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
I am getting,
javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Unknown Source)
at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.recvAlert(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRecord(Unknown Source)
at com.sun.net.ssl.internal.ssl.AppOutputStream.write(Unknown Source)
at java.io.OutputStream.write(Unknown Source)
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.test(Push.java:132)
at javapns.test.NotificationTest.pushTest(NotificationTest.java:83)
at javapns.test.NotificationTest.main(NotificationTest.java:46)
After debugging the JavaPNS code in eclipse i come to know the error was due to,
java.io.EOFException: SSL peer shut down incorrectly
Now i am not understanding what is the problem, as my certificates (with .PEM extensions) works fine with PHP example.
If its working in PHP and not in Java i am doubtful weather its certificates' fault, and JavaPNS site also not specified weather i have to import the generated certificates through keytool
or not.
Can anyone please help me solve my problem? FYI: My System Configuration, OS: Win 7 Java : jdk1.6.0_05 JavaPNS : 2.2
Upvotes: 1
Views: 3162
Reputation: 382
Finally i found answer to my question,
Its the certificate. The thing is, there are 2 certificates with the same URL (com.xxx.xxx) and because of which the confusion occurred.
I have removed the one not used by the device and created a new .p12 from the one used in the device and Bingo, it worked.
Upvotes: 1