【问题标题】:Couldn't able to connect to APNS Sandbox server无法连接到 APNS 沙盒服务器
【发布时间】:2011-10-10 06:00:14
【问题描述】:

我正在尝试通过以下观察连接到 Apple APNS 服务器:

1) 端口 2195 已打开 2) 使用 APNS_SSLCertificate_Key.pem 的有效密钥密码 3) 从 https://www.entrust.net/downloads/binary/entrust_ssl_ca.cer 下载的委托证书 (2048)

4) 成功的 telnet 响应如下:

$ telnet gateway.sandbox.push.apple.com 2195 正在尝试 17.172.232.226... 连接到 gateway.sandbox.push-apple.com.akadns.net。逃脱 字符是'^]'。

但是当我在我的服务器中运行以下 openssl 命令来测试 APNS 连接性时:

openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert  APNS_SSLCertificate_Key.pem -debug -showcerts -CAfile server-ca-cert.pem

我收到如下错误:

无法加载证书 57013:error:0906D06C:PEM 例程:PEM_read_bio:没有开始 行:/SourceCache/OpenSSL098/OpenSSL098-35/src/crypto/pem/pem_lib.c:650:预期: 受信任的证书

所以请建议如何解决这个问题

提前致谢......

【问题讨论】:

    标签: ssl push push-notification apple-push-notifications


    【解决方案1】:

    我遇到了同样的问题;最终解决该错误的方法是从 OS/X Keychain Access 应用程序的系统根目录重新导出 Entrust 证书。

    为了完整起见,我将完整解释我是如何创建密钥/证书文件的(应该在 Apple 的技术说明 2265 中:https://developer.apple.com/library/content/technotes/tn2265/_index.html

    创建您的 APN 证书和密钥:

    1. 运行钥匙串访问;选择“登录”钥匙串和“我的证书”类别
    2. 选择名称格式为“Apple Development IOS Push Services: ...”的证书
    3. 导出证书(在菜单中的“文件”..“导出项目”下)
    4. 导出为 .p12 格式。
      这现在包含加密交换格式的证书和私钥。下一步是将其转换为受密码保护的 .pem 文件
    5. 使用终端,执行以下命令(当然使用您自己的文件名):

      openssl pkcs12 -in PushCertKey.p12 -out PushCertKey.pem

      (您需要输入 .p12 文件的密码并为 .pem 文件提供另一个密码。)

      如果您真的真的不想在 .pem 文件中设置密码,请尝试:

      openssl pkcs12 -in PushCertKey.p12 -out PushCertKeyNoCrypt.pem -nodes

    创建 CA 证书文件:

    1. 列表项
    2. 运行钥匙串访问应用程序
    3. 转到系统根目录
    4. 将名为“Entrust.net 证书颁发机构 (2048)”的证书导出到 .pem 文件。

      注意:My Roots 容器有四个 Entrust 证书;其中两个名称为“Entrust.net 证书颁发机构(2048)”(但具有不同的证书扩展名,通过获取信息)。两个“Entrust.net 证书颁发机构(2048)”证书在验证信任链时均有效;其他两个 Entrust 证书无效。更重要的是,Apple TechNote 2265 指向的 Entrust 证书也不起作用。

      确保导出为 .pem 格式;默认为 .cer,这一步很容易错过。

    运行验证命令:

    openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert PushCertKey.pem -debug -showcerts -CAfile "Entrust.net Certification Authority (2048).pem" 
    

    此服务器和进程假定您正在连接到 Apple 的 Dev 沙盒 APN 服务器;如果您尝试使用生产 APN 服务器,则需要使用正确的服务器和端口。

    有关 openssl 的更多信息,我建议以下页面:

    【讨论】:

    • 在命令行中将 Entrust 证书(我使用技术说明中链接的那个)从 .cer 转换为 PEM 格式:openssl x509 -in entrust.cer -out entrust.pem
    • 您可以从entrust.net/downloads/root_request.cfm#获取Entrust CA证书entrust_2048_ca.cer,它已经是pem格式了。
    【解决方案2】:

    SSL 问题:逐步修复。 大部分问题是由于私钥问题,可以通过以下方式解决。

    按照以下命令并使用 openssl 创建 .p12。

    1. 你需要 developer_identity.cer

    2. 在配置、安装或运行 openssl 的终端中运行这些命令:

      • openssl x509 -in developer_identity.cer -inform DER -out developer_identity.pem -outform PEM
      • openssl pkcs12 -nocerts -in mykey.p12 -out mykey.pem
      • openssl pkcs12 -export -inkey mykey.pem -in developer_identity.pem -out iphone_dev.p12

    您需要的最终 p12 是 iphone_dev.p12 文件和您设置的密码。

    再试一次,希望你的问题得到解决,就像我一直这样。 :)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-07-07
      • 2013-11-08
      • 1970-01-01
      • 2016-04-19
      • 2015-01-03
      • 1970-01-01
      相关资源
      最近更新 更多