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 
相關問題