【问题标题】:Apple APNS and "Entrust Secure CA root certificate"?Apple APNS 和“委托安全 CA 根证书”?
【发布时间】: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


【解决方案1】:

我找到了解决方案。作为向我提出建议的人,我不知道为什么它解决了这个问题。

使用 OpenSSL,我已将 P12 文件(我从 Keychain Access 获得)转换为 PEM,然后从 PEM 转换回 P12...

  1. 将从应用的 APN(位于 developer.apple.com)下载的 CER 文件转换为 PEM
    openssl x509 -in aps_development.cer -inform DER -out aps_development.pem -outform PEM

  2. 将使用钥匙串访问创建的 P12 文件转换为 PEM
    openssl pkcs12 -nocerts -in Certificates.p12 -out Certificates.pem

  3. 创建一个新的 GOOD P12 文件
    openssl pkcs12 -export -inkey Certificates.pem -in aps_development.pem -out GOOD_Certificates.p12

欲了解更多信息:http://help.adobe.com/en_US/as3/iphone/WS144092a96ffef7cc-371badff126abc17b1f-7fff.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-02-29
    • 2021-01-17
    • 2019-11-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多