我試圖將推送通知發送到iOS設備。
我爲APNS創建了一個開發人員證書,並將其與應用程序標識符綁定在一起。Apple APNS和「Entrust安全CA根證書」?
我接着就用愛出風頭(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
。
我用我已經從我與應用結合的證書的私鑰創建的P12文件在developer.apple.com
多搜索我已經後設法獲得一些信息,爲什麼我不能得到這個東西的工作,在Apple Doc:
Note: To establish a TLS session with APNs, an Entrust Secure CA root certificate must be installed on the provider’s server. If the server is running OS X, this root certificate is already in the keychain. On other systems, the certificate might not be available. You can download this certificate from the Entrust SSL Certificates website.
不過,我仍然不知道我該做的。
我真的很感激這裏的一些更具體的指導。
謝謝。
你是如何創建的P12文件?你是否從keytool應用程序導出證書+私鑰? – Eran
我在OS X上,所以我只是使用Keychain Access導出私鑰。 – thedp
我的意思是KeyChain Access應用程序(我忘了名字)。您應該選擇推送證書和私鑰並將其導出到p12文件。 – Eran