3

我在开发"provider" in APNS时遇到了问题。我的服务器试图使用apns-client发送消息,发送消息时似乎没有问题,但设备根本没有收到任何消息。查找APNS认证文件是否有效的替代方法?

最近我将* .pem文件更改为新的。在使用前一个* .pem文件时正确接收了消息,因此我确信在服务器连接和发送脚本(用Python编写)时没有问题。原因可能是因为旧的* .pem文件是有效的,但新的* .pem文件不是。

如果* .pem文件无效,我强烈希望来自APNS服务器的“错误”响应,但似乎APNS服务器或apns-client库即使*也没有返回任何错误信号。 pem文件无效。我已经通过在* .pem中的-----END RSA PRIVATE KEY-----之前添加一百个'a'来证明这一点,并且运行相同的python脚本。是的,它仍然没有收到任何错误消息。

由于APNS服务器没有返回错误消息,几乎不可能检查* .pem文件是否有效......是否有任何方法检查* .pem文件是否有效?

+0

当我产生我的证书就问我一些关键这是我从钥匙链中导出时指定的。当我启动应用程序时,它要求我在控制台中输入密钥,我确信我的证书可以正确加载,然后我只需删除此密钥。还有一件事我注意到,如果你删除你的配置文件,它不会打印任何东西 –

回答

2

我不熟悉您使用的python客户端,但肯定有一种方法可以简单地尝试打开与Apple的PNS服务器的连接并检测连接是否失败。如果连接失败,那么PEM文件有问题 - 格式或证书值本身。

如果您想要获得比“通过或失败”更具说明性的错误消息,我建议您查看第三方shell脚本,该脚本可以返回有关PEM文件的一些基本信息。这个thread包含一些示例脚本。

当然,您还可以检查一些可广泛使用的基本格式验证。我提供了一个这样的例子here,但也有其他的例子。

4

这是一个被Apple提出了一些故障排除信息:

Problems Connecting to the Push Service

One possibility is that your server is unable to connect to the push service. This can mean that you don't have the certificate chain needed for TLS/SSL to validate the connection to the service. In addition to the SSL identity (certificate and associated private key) created by Member Center, you should also install the Entrust CA (2048) root certificate on your provider. This allows TLS/SSL to verify the full APNs server cert chain. If you need to get this root certificate, you can download it from Entrust's site. Also verify that these identities are installed in the correct location for your provider and that your provider has permission to read them.

You can test the TLS/SSL handshake using the OpenSSL s_client command, like this:

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

where server-ca-cert.pem is the Entrust CA (2048) root certificate.

Be sure the SSL identity and the hostname are the correct ones for the push environment you're testing. You can configure your App ID in Member Center separately for the sandbox and production environment, and you will be issued a separate identity for each environment.

Using the sandbox SSL identity to try to connect to the production environment will return an error like this:

CRITICAL | 14:48:40.304061 | Exception creating ssl connection to Apple: [Errno 1] _ssl.c:480: error:14094414:SSL routines:SSL3_READ_BYTES:sslv3 alert certificate revoked

+0

Entrust CA(2048)已经存在,但在证书链中,我可以看到一条消息“无法找到该证书的签发者。”而不是“这个证书是好的。” –

1

要测试你生产证书,打开终端,并做到这一点:

openssl s_client -connect gateway.push.apple.com:2195 -cert PushProdCer.pem -key PushProdKey.pem 
相关问题