苹果推送通知 SSLHandshakeException

Posted

技术标签:

【中文标题】苹果推送通知 SSLHandshakeException【英文标题】:Apple Push Notification SSLHandshakeException 【发布时间】:2016-07-23 13:04:58 【问题描述】:

环境:

    Windows Server 2012 R2 JRE 1.8.0_101 IBM WAS Liberty Core 8.5.5.5 IBM MFP 7.1.0.00.20150913-2345

APNS 端口已启用:

    gateway.sandbox.push.apple.com 2195 gateway.push.apple.com 2195

通过 telnet 验证它正在连接。

iPhone 版本已使用 Eclipse Studio 进行了测试,它工作正常,但指向远程服务器的相同点会出现以下错误。

    [7/23/16 16:02:49:822 GST] 00000126 om.ibm.pushworks.server.notification.apns.ApnsConnectionImpl I Failed to send message Message(Id=2; Token=sdfsadfsdfsdfsdfsdf; Payload="payload":"\"tag\":\"Push.ALL\"","aps":"alert":"action-loc-key":null,"body":"مرحبا كيف حالك اليوم؟")... trying again after delay
javax.net.ssl.SSLHandshakeException: Received fatal alert: certificate_unknown
    at sun.security.ssl.Alerts.getSSLException(Unknown Source)
    at sun.security.ssl.Alerts.getSSLException(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.recvAlert(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.writeRecord(Unknown Source)
    at sun.security.ssl.AppOutputStream.write(Unknown Source)
    at java.io.OutputStream.write(Unknown Source)
    at com.ibm.pushworks.server.notification.apns.ApnsConnectionImpl.sendMessage(ApnsConnectionImpl.java:302)
    at com.ibm.pushworks.server.notification.apns.ApnsConnectionImpl.sendMessage(ApnsConnectionImpl.java:292)
    at com.notnoop.apns.internal.ApnsPooledConnection$2.run(ApnsPooledConnection.java:47)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

[7/23/16 16:02:49:838 GST] 00000125 om.ibm.pushworks.server.notification.apns.ApnsConnectionImpl I Failed to send message Message(Id=1; Token=sgaskjgsdkahdsfgksadhfgksdhfgsakdjfhgasdkhfds; Payload="payload":"\"tag\":\"Push.ALL\"","aps":"alert":"action-loc-key":null,"body":"مرحبا كيف حالك اليوم؟")... trying again after delay
javax.net.ssl.SSLHandshakeException: Received fatal alert: certificate_unknown
    at sun.security.ssl.Alerts.getSSLException(Unknown Source)
    at sun.security.ssl.Alerts.getSSLException(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.recvAlert(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.writeRecord(Unknown Source)
    at sun.security.ssl.AppOutputStream.write(Unknown Source)
    at java.io.OutputStream.write(Unknown Source)
    at com.ibm.pushworks.server.notification.apns.ApnsConnectionImpl.sendMessage(ApnsConnectionImpl.java:302)
    at com.ibm.pushworks.server.notification.apns.ApnsConnectionImpl.sendMessage(ApnsConnectionImpl.java:292)
    at com.notnoop.apns.internal.ApnsPooledConnection$2.run(ApnsPooledConnection.java:47)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

[7/23/16 16:02:51:501 GST] 00000125 om.ibm.pushworks.server.notification.apns.ApnsConnectionImpl E Couldn't send message after 3 retries.Message(Id=1; Token=sgaskjgsdkahdsfgksadhfgksdhfgsakdjfhgasdkhfds; Payload="payload":"\"tag\":\"Push.ALL\"","aps":"alert":"action-loc-key":null,"body":"مرحبا كيف حالك اليوم؟")
javax.net.ssl.SSLHandshakeException: Received fatal alert: certificate_unknown
    at sun.security.ssl.Alerts.getSSLException(Unknown Source)
    at sun.security.ssl.Alerts.getSSLException(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.recvAlert(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.writeRecord(Unknown Source)
    at sun.security.ssl.AppOutputStream.write(Unknown Source)
    at java.io.OutputStream.write(Unknown Source)
    at com.ibm.pushworks.server.notification.apns.ApnsConnectionImpl.sendMessage(ApnsConnectionImpl.java:302)
    at com.ibm.pushworks.server.notification.apns.ApnsConnectionImpl.sendMessage(ApnsConnectionImpl.java:292)
    at com.notnoop.apns.internal.ApnsPooledConnection$2.run(ApnsPooledConnection.java:47)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

[7/23/16 16:02:51:501 GST] 00000125 ibm.pushworks.server.notification.apns.ApplicationConnection E FPWSE1083E: Failed to send APNS notification with identifier 1, device token: sgaskjgsdkahdsfgksadhfgksdhfgsakdjfhgasdkhfds
javax.net.ssl.SSLHandshakeException: Received fatal alert: certificate_unknown
    at sun.security.ssl.Alerts.getSSLException(Unknown Source)
    at sun.security.ssl.Alerts.getSSLException(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.recvAlert(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.writeRecord(Unknown Source)
    at sun.security.ssl.AppOutputStream.write(Unknown Source)
    at java.io.OutputStream.write(Unknown Source)
    at com.ibm.pushworks.server.notification.apns.ApnsConnectionImpl.sendMessage(ApnsConnectionImpl.java:302)
    at com.ibm.pushworks.server.notification.apns.ApnsConnectionImpl.sendMessage(ApnsConnectionImpl.java:292)
    at com.notnoop.apns.internal.ApnsPooledConnection$2.run(ApnsPooledConnection.java:47)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

[7/23/16 16:02:51:516 GST] 00000125 SystemErr                                                    R Exception in thread "pool-5-thread-1" 
[7/23/16 16:02:51:516 GST] 00000125 SystemErr                                                    R com.notnoop.exceptions.NetworkIOException: javax.net.ssl.SSLHandshakeException: Received fatal alert: certificate_unknown
[7/23/16 16:02:51:516 GST] 00000125 SystemErr                                                    R  at com.notnoop.apns.internal.Utilities.wrapAndThrowAsRuntimeException(Utilities.java:277)
[7/23/16 16:02:51:516 GST] 00000125 SystemErr                                                    R  at com.ibm.pushworks.server.notification.apns.ApnsConnectionImpl.sendMessage(ApnsConnectionImpl.java:319)
[7/23/16 16:02:51:516 GST] 00000125 SystemErr                                                    R  at com.ibm.pushworks.server.notification.apns.ApnsConnectionImpl.sendMessage(ApnsConnectionImpl.java:292)
[7/23/16 16:02:51:516 GST] 00000125 SystemErr                                                    R  at com.notnoop.apns.internal.ApnsPooledConnection$2.run(ApnsPooledConnection.java:47)
[7/23/16 16:02:51:516 GST] 00000125 SystemErr                                                    R  at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
[7/23/16 16:02:51:516 GST] 00000125 SystemErr                                                    R  at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
[7/23/16 16:02:51:516 GST] 00000125 SystemErr                                                    R  at java.lang.Thread.run(Unknown Source)
[7/23/16 16:02:51:516 GST] 00000125 SystemErr                                                    R Caused by: javax.net.ssl.SSLHandshakeException: Received fatal alert: certificate_unknown
[7/23/16 16:02:51:516 GST] 00000125 SystemErr                                                    R  at sun.security.ssl.Alerts.getSSLException(Unknown Source)
[7/23/16 16:02:51:516 GST] 00000125 SystemErr                                                    R  at sun.security.ssl.Alerts.getSSLException(Unknown Source)
[7/23/16 16:02:51:516 GST] 00000125 SystemErr                                                    R  at sun.security.ssl.SSLSocketImpl.recvAlert(Unknown Source)
[7/23/16 16:02:51:516 GST] 00000125 SystemErr                                                    R  at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
[7/23/16 16:02:51:516 GST] 00000125 SystemErr                                                    R  at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
[7/23/16 16:02:51:516 GST] 00000125 SystemErr                                                    R  at sun.security.ssl.SSLSocketImpl.writeRecord(Unknown Source)
[7/23/16 16:02:51:516 GST] 00000125 SystemErr                                                    R  at sun.security.ssl.AppOutputStream.write(Unknown Source)
[7/23/16 16:02:51:516 GST] 00000125 SystemErr                                                    R  at java.io.OutputStream.write(Unknown Source)
[7/23/16 16:02:51:516 GST] 00000125 SystemErr                                                    R  at com.ibm.pushworks.server.notification.apns.ApnsConnectionImpl.sendMessage(ApnsConnectionImpl.java:302)
[7/23/16 16:02:51:516 GST] 00000125 SystemErr                                                    R  ... 5 more
[7/23/16 16:02:51:516 GST] 00000126 om.ibm.pushworks.server.notification.apns.ApnsConnectionImpl E Couldn't send message after 3 retries.Message(Id=2; Token=sdfsadfsdfsdfsdfsdf; Payload="payload":"\"tag\":\"Push.ALL\"","aps":"alert":"action-loc-key":null,"body":"مرحبا كيف حالك اليوم؟")
javax.net.ssl.SSLHandshakeException: Received fatal alert: certificate_unknown
    at sun.security.ssl.Alerts.getSSLException(Unknown Source)
    at sun.security.ssl.Alerts.getSSLException(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.recvAlert(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.writeRecord(Unknown Source)
    at sun.security.ssl.AppOutputStream.write(Unknown Source)
    at java.io.OutputStream.write(Unknown Source)
    at com.ibm.pushworks.server.notification.apns.ApnsConnectionImpl.sendMessage(ApnsConnectionImpl.java:302)
    at com.ibm.pushworks.server.notification.apns.ApnsConnectionImpl.sendMessage(ApnsConnectionImpl.java:292)
    at com.notnoop.apns.internal.ApnsPooledConnection$2.run(ApnsPooledConnection.java:47)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

[7/23/16 16:02:51:516 GST] 00000126 ibm.pushworks.server.notification.apns.ApplicationConnection E FPWSE1083E: Failed to send APNS notification with identifier 2, device token: sdfsadfsdfsdfsdfsdf
javax.net.ssl.SSLHandshakeException: Received fatal alert: certificate_unknown
    at sun.security.ssl.Alerts.getSSLException(Unknown Source)
    at sun.security.ssl.Alerts.getSSLException(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.recvAlert(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.writeRecord(Unknown Source)
    at sun.security.ssl.AppOutputStream.write(Unknown Source)
    at java.io.OutputStream.write(Unknown Source)
    at com.ibm.pushworks.server.notification.apns.ApnsConnectionImpl.sendMessage(ApnsConnectionImpl.java:302)
    at com.ibm.pushworks.server.notification.apns.ApnsConnectionImpl.sendMessage(ApnsConnectionImpl.java:292)
    at com.notnoop.apns.internal.ApnsPooledConnection$2.run(ApnsPooledConnection.java:47)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

[7/23/16 16:02:51:516 GST] 00000126 SystemErr                                                    R Exception in thread "pool-5-thread-2" 
[7/23/16 16:02:51:516 GST] 00000126 SystemErr                                                    R com.notnoop.exceptions.NetworkIOException: javax.net.ssl.SSLHandshakeException: Received fatal alert: certificate_unknown
[7/23/16 16:02:51:516 GST] 00000126 SystemErr                                                    R  at com.notnoop.apns.internal.Utilities.wrapAndThrowAsRuntimeException(Utilities.java:277)
[7/23/16 16:02:51:516 GST] 00000126 SystemErr                                                    R  at com.ibm.pushworks.server.notification.apns.ApnsConnectionImpl.sendMessage(ApnsConnectionImpl.java:319)
[7/23/16 16:02:51:516 GST] 00000126 SystemErr                                                    R  at com.ibm.pushworks.server.notification.apns.ApnsConnectionImpl.sendMessage(ApnsConnectionImpl.java:292)
[7/23/16 16:02:51:516 GST] 00000126 SystemErr                                                    R  at com.notnoop.apns.internal.ApnsPooledConnection$2.run(ApnsPooledConnection.java:47)
[7/23/16 16:02:51:516 GST] 00000126 SystemErr                                                    R  at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
[7/23/16 16:02:51:516 GST] 00000126 SystemErr                                                    R  at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
[7/23/16 16:02:51:516 GST] 00000126 SystemErr                                                    R  at java.lang.Thread.run(Unknown Source)
[7/23/16 16:02:51:516 GST] 00000126 SystemErr                                                    R Caused by: javax.net.ssl.SSLHandshakeException: Received fatal alert: certificate_unknown
[7/23/16 16:02:51:516 GST] 00000126 SystemErr                                                    R  at sun.security.ssl.Alerts.getSSLException(Unknown Source)
[7/23/16 16:02:51:516 GST] 00000126 SystemErr                                                    R  at sun.security.ssl.Alerts.getSSLException(Unknown Source)
[7/23/16 16:02:51:516 GST] 00000126 SystemErr                                                    R  at sun.security.ssl.SSLSocketImpl.recvAlert(Unknown Source)
[7/23/16 16:02:51:516 GST] 00000126 SystemErr                                                    R  at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
[7/23/16 16:02:51:516 GST] 00000126 SystemErr                                                    R  at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
[7/23/16 16:02:51:516 GST] 00000126 SystemErr                                                    R  at sun.security.ssl.SSLSocketImpl.writeRecord(Unknown Source)
[7/23/16 16:02:51:516 GST] 00000126 SystemErr                                                    R  at sun.security.ssl.AppOutputStream.write(Unknown Source)
[7/23/16 16:02:51:516 GST] 00000126 SystemErr                                                    R  at java.io.OutputStream.write(Unknown Source)
[7/23/16 16:02:51:516 GST] 00000126 SystemErr                                                    R  at com.ibm.pushworks.server.notification.apns.ApnsConnectionImpl.sendMessage(ApnsConnectionImpl.java:302)
[7/23/16 16:02:51:516 GST] 00000126 SystemErr                                                    R  ... 5 more

【问题讨论】:

【参考方案1】:

这通常是由于安装服务器的机器(开发与生产)之间的 Java 版本不同造成的。例如:

Unauthorized access was denied or security settings have expired javax.net.ssl.SSLException: certificate_unknown when creating MobileFirst runtime

如果不是所有端口都打开也可能发生,例如对于反馈服务:

feedback.push.apple.com,端口 2196 端口 2196 上的 feedback.sandbox.push.apple.com

【讨论】:

feedback.push.apple.com,端口 2196 端口 2196 上的 feedback.sandbox.push.apple.com 可通过 telnet 访问。另外,我想了解 Java 版本在 Dev 与 Prod 中是否有所不同。如果这是真的,我应该使用哪个版本,因为我已经尝试过使用 JRE 7 和 JRE 8。但仍然没有运气。我在调用推送通知时遇到的异常,但在创建 MFP 运行时时却没有

以上是关于苹果推送通知 SSLHandshakeException的主要内容,如果未能解决你的问题,请参考以下文章

应用在前台时如何触发苹果推送通知事件?

无需使用互联网、wifi、APNS 和苹果推送通知服务器即可推送通知

苹果推送通知错误

苹果推送通知,定期发出声音嗡嗡声

苹果推送通知声音

Azure 通知中心不会发送苹果推送通知