Ho un problema con le notifiche push. Ho un certificato p.12 che è stato creato da un membro del team e ho il token dispositivo per il dispositivo a cui essere spinto. Sto usando la libreria javapns di fare il push (provato anche i javaapns Lib con gli stessi risultati), ma continuo a ricevere questo errore:Impossibile inviare notifiche push utilizzando l'errore di handshake SSL Javapns/Javaapns
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:1720)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:954)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1138)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:632)
at com.sun.net.ssl.internal.ssl.AppOutputStream.write(AppOutputStream.java:59)
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.combined(Push.java:100)
at PushTest.push(PushTest.java:43)
at PushTest.main(PushTest.java:25)
e questo è il codice che sto usando per testare
try {
List<PushedNotification> n = Push.combined(text, 20, null, file, "********", false, token);
for (PushedNotification notification : n) {
if (notification.isSuccessful())
System.out.println("Push notification sent successfully to: " + notification.getDevice().getToken());
else {
String invalidToken = notification.getDevice().getToken();
Exception theProblem = notification.getException();
theProblem.printStackTrace();
ResponsePacket theErrorResponse = notification.getResponse();
if (theErrorResponse != null)
System.out.println(theErrorResponse.getMessage());
}
}
}
catch (CommunicationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (KeystoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Ho letto e provato i suggerimenti di molti altri post, inclusa l'importazione del certificato nel keystore di cacerts, ma l'importazione ha avuto esito negativo. Sto sviluppando usando eclipse su una macchina Windows.
Qualcuno ha familiarità con questo problema? Sono nuovo nell'usare ssl quindi forse sto facendo qualcosa di sbagliato o non posso usare un certificato generato su un'altra macchina?
grazie salvami la vita. – aybars
Solo wow! Esportando incredibilmente il certificato e la chiave privata come p12 dal portachiavi non ha funzionato. Ma la tua soluzione ha funzionato. – Elendir