【发布时间】:2014-06-07 23:28:17
【问题描述】:
我正在尝试向 iOS 设备发送推送通知。
我为 APNS 创建了一个开发者证书并将其与应用程序标识符绑定。
然后我继续使用 Pushy (https://github.com/relayrides/pushy) 建立与 APNS 服务器的连接:
final PushManagerFactory<SimpleApnsPushNotification> pushManagerFactory =
new PushManagerFactory<SimpleApnsPushNotification>(
ApnsEnvironment.getSandboxEnvironment(),
PushManagerFactory.createDefaultSSLContext( DEV_CERT_P12__PATH, DEV_CERT_P12__PASSWORD )
);
final PushManager<SimpleApnsPushNotification> pushManager = pushManagerFactory.buildPushManager();
pushManager.registerFailedConnectionListener(new MyFailedConnectionListener());
pushManager.start();
....
public static class MyFailedConnectionListener implements FailedConnectionListener<SimpleApnsPushNotification> {
public void handleFailedConnection(
final PushManager<? extends SimpleApnsPushNotification> pushManager,
final Throwable cause) {
System.out.println("ERROR - "+ cause.toString());
if (cause instanceof SSLHandshakeException) {
// This is probably a permanent failure, and we should shut down
// the PushManager.
}
}
}
我收到此错误:javax.net.ssl.SSLException: Received fatal alert: certificate_unknown。
我正在使用从我与 developer.apple.com 上的应用程序绑定的证书的私钥创建的 P12 文件
经过大量搜索,我设法在Apple Doc 中获得了一些关于为什么我不能让这个东西工作的信息:
注意:要与 APNs 建立 TLS 会话,Entrust Secure CA 根 证书必须安装在提供商的服务器上。如果服务器 正在运行 OS X,此根证书已在钥匙串中。在 其他系统,证书可能不可用。你可以 从 Entrust SSL 证书网站下载此证书。
但是,我仍然不知道我应该做什么。
我真的很感激这里有一些更具体的指导。
谢谢。
【问题讨论】:
-
您是如何创建 p12 文件的?您是否从 keytool 应用中导出了证书+私钥?
-
我在 OS X 上,所以我只是用钥匙串访问导出了私钥。
-
我的意思是 KeyChain Access 应用程序(我忘记了名字)。您应该选择推送证书和私钥并将它们导出到 p12 文件。
-
@Eran 还是同样的错误。我已经用截图更新了问题。
-
您是否在 Mac 上本地运行服务器?
标签: java apple-push-notifications certificate