当前位置: 首页 > 工具软件 > JavaPNS > 使用案例 >

java apns ssl错误_无法使用Javapns/Javaapns SSL握手失败发送推送通知

权承
2023-12-01

我有推送通知的问题。我有一个由团队成员创建的p.12证书,并且具有要推送到设备的设备令牌。我正在使用javapns库来做推送(也尝试了同样的结果的javaapns lib),但是我不断得到这个错误:

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 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密钥库中,但导入失败。我正在开发使用eclipse在windows机器上。

任何熟悉这个问题的人?我是新来使用ssl,所以也许我做错了,是不是我不能使用在另一台机器上生成的证书?

 类似资料: