我遇到推送通知問題。我有一個由團隊成員創建的p.12證書,並且具有要推送到的設備令牌。我現在用的是javapns庫做推(也試過javaapns LIB具有相同的結果),但我不斷收到此錯誤:無法使用Javapns/Javaapns發送推送通知SSL握手失敗
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)
,這是我使用測試
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();
}
代碼
我閱讀並嘗試了其他幾個帖子的建議,包括將證書導入cacerts密鑰庫,但導入也失敗。我正在開發在Windows機器上使用eclipse。
任何人都熟悉這個問題?我是新來的使用ssl所以也許我做錯了什麼,或者是我不能使用另一臺機器上生成的證書?
謝謝救救我的生命。 – aybars
只是哇!令人驚訝的是,從鑰匙串中導出證書和私鑰作爲p12不起作用。但你的解決方案。 – Elendir