使用本地Liberty服务器解决SSL错误

时间:2013-11-01 17:37:40

标签: ibm-mobilefirst worklight-adapters worklight-server

我从新项目中定义的示例推送通知中获取PushAdapter,并且我已将apns-certificate-sandbox.p12添加到本机api应用程序(本机api),在其中添加了正确的bundleId值application-descriptor.xml,但是,我一直收到这个错误:

[WARNING ] Failed to retreive invalid devices
javax.net.ssl.SSLHandshakeException: Received fatal alert: certificate_unknown
[ERROR   ] Couldn't get feedback connection
javax.net.ssl.SSLHandshakeException: Received fatal alert: certificate_unknown
[ERROR   ] Unknown exception: javax.net.ssl.SSLHandshakeException: Received fatal alert: certificate_unknown
Unknown exception: javax.net.ssl.SSLHandshakeException: Received fatal alert: certificate_unknown

这是Worklight的新安装(6.0.0.20130909-1459),我尝试了两个单独的安装(一个安装到Eclipse,一个安装到RAD),两个都是相同的错误。

是否需要进行一些额外的工作才能使推送测试在Worklight Development Server(Websphere Liberty)环境中工作以使SSL正常工作?尚未订阅任何设备,但是,不确定为什么会发生此错误或者它是否相关。

详细的痕迹在这里:

[11/1/13 11:50:20:834 EDT] 00000034 com.worklight.core.exceptions.InstrumentedException          E Unknown exception: javax.net.ssl.SSLHandshakeException: Received fatal alert: certificate_unknown
com.worklight.core.exceptions.InstrumentedException: Unknown exception: javax.net.ssl.SSLHandshakeException: Received fatal alert: certificate_unknown
    at com.worklight.core.exceptions.DefaultExceptionHandler.handleException(DefaultExceptionHandler.java:56)
    at com.worklight.core.tasks.TaskThread.run(TaskThread.java:113)
Caused by: java.lang.RuntimeException: javax.net.ssl.SSLHandshakeException: Received fatal alert: certificate_unknown
    at com.notnoop.apns.internal.Utilities.parseFeedbackStreamRaw(Utilities.java:201)
    at com.notnoop.apns.internal.Utilities.parseFeedbackStream(Utilities.java:211)
    at com.notnoop.apns.internal.ApnsFeedbackConnection.getInactiveDevicesImpl(ApnsFeedbackConnection.java:87)
    at com.notnoop.apns.internal.ApnsFeedbackConnection.getInactiveDevices(ApnsFeedbackConnection.java:67)
    at com.notnoop.apns.internal.AbstractApnsService.getInactiveDevices(AbstractApnsService.java:99)
    at com.notnoop.apns.internal.ApnsServiceImpl.getInactiveDevices(ApnsServiceImpl.java:36)
    at com.worklight.integration.notification.apns.ApplicationConnection.getInactiveDevices(ApplicationConnection.java:110)
    at com.worklight.integration.notification.apns.APNSMediator.maintain(APNSMediator.java:95)
    at com.worklight.integration.notification.Dispatcher.maintain(Dispatcher.java:148)
    at com.worklight.integration.notification.NotificationCleanupTask.step(NotificationCleanupTask.java:29)
    at com.worklight.core.tasks.TaskThread.run(TaskThread.java:111)
Caused by: javax.net.ssl.SSLHandshakeException: Received fatal alert: certificate_unknown
    at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
    at sun.security.ssl.Alerts.getSSLException(Alerts.java:154)
    at sun.security.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:1961)
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1077)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1312)
    at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:882)
    at sun.security.ssl.AppInputStream.read(AppInputStream.java:102)
    at sun.security.ssl.AppInputStream.read(AppInputStream.java:69)
    at java.io.DataInputStream.readInt(DataInputStream.java:387)
    at com.notnoop.apns.internal.Utilities.parseFeedbackStreamRaw(Utilities.java:192)
    ... 10 more

3 个答案:

答案 0 :(得分:2)

这似乎是服务器尝试测试与Apple推送/反馈服务的连接时的错误。

要检查的几件事情:

  1. 是否为开发或分发构建了应用程序?
  2. 如果是开发,请确保您使用的是开发SSL证书。将证书和私钥导出到名为:apns-certificate-sandbox.p12
  3. 的文件中
  4. 如果是分发,请确保您使用的是生产SSL证书。将证书和私钥导出到名为:apns-certificate-production.p12
  5. 的文件中
  6. 确保正确创建.p12文件,并在应用程序描述符文件中指定了相应的密码。
  7. 确保您的Worklight服务器可以访问APN主机/端口以进行推送和反馈服务。即需要为以下内容打开防火墙端口:
    • gateway.push.apple.com,port 2195
    • gateway.sandbox.push.apple.com,port 2195
    • feedback.push.apple.com,port 2196
    • feedback.sandbox.push.apple.com on port 2196

答案 1 :(得分:1)

Worklight产品从未使用http://code.google.com/p/javapns进行推送,它使用的是com.notnoop.apns。该软件包适用于Oracle JDK 1.6和1.7 您能否详细介绍一下您使用的JDK版本? 我在嵌入式Liberty + Oracle JDK 1.7_07b + iPhone 5上测试了push sample并且它运行良好。 你是如何创建这个证书的?你能一步一步地写下你做了什么吗? (并指定您复制的每个文件,一路编辑)

如果你问的是使用javaPNS:Ofcourse,因为它是一个开放的框架,你可以手动将任何jar复制(并使用)到你的Worklight项目中作为第三方依赖,但是,似乎这个javaPNS jar有一些bug使用SSL。

为什么不查看Worklight的推送通知示例并从那里开始工作(http://www.ibm.com/developerworks/mobile/worklight/getting-started.html#client-basics)? (Worklight附带一个工作推送通知解决方案,适用于JDK1.6或1.7而不会出现PKCS12证书问题)

答案 2 :(得分:0)

就我而言,已经证实在OS X中(有时在Windows中实际上),使用JRE 7而不是JRE 6时会抛出certificate_unknown错误。似乎notnoop开源库使用了Worklight无法很好地处理Java 7。

https://github.com/notnoop/java-apns/issues/54