SSLHandshakeException未知\u ca apns java

SSLHandshakeException未知\u ca apns java,java,iphone,push-notification,sslhandshakeexception,Java,Iphone,Push Notification,Sslhandshakeexception,我正在尝试为iphone实现一个独立的应用程序;我希望在iphone客户端使用Apple推送通知。 我收到javax.net.ssl.SSLHandshakeException:收到致命警报:未知\u ca 以下是我连接到apns网关的Java代码: int port = 2195; String hostname = "gateway.sandbox.push.apple.com"; char[] passwKey = "password".toCharArray(); KeyStore t

我正在尝试为iphone实现一个独立的应用程序;我希望在iphone客户端使用Apple推送通知。 我收到javax.net.ssl.SSLHandshakeException:收到致命警报:未知\u ca 以下是我连接到apns网关的Java代码:

int port = 2195;
String hostname = "gateway.sandbox.push.apple.com";
char[] passwKey = "password".toCharArray();

KeyStore ts = KeyStore.getInstance("PKCS12");
ts.load(new FileInputStream("/path/to/file/Cert.p12"), passwKey);
KeyManagerFactory tmf = KeyManagerFactory.getInstance("SunX509");
tmf.init(ts, passwKey);

SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(tmf.getKeyManagers(), null, null);
SSLSocketFactory factory = sslContext.getSocketFactory();

SSLSocket socket = (SSLSocket) factory.createSocket(hostname,port); 
String[] suites = socket.getSupportedCipherSuites();
socket.setEnabledCipherSuites(suites);
//start handshake
socket.startHandshake(); 
请帮助我了解什么以及如何在我的Linux机器上安装ssl证书

编辑:

它现在对我有效,我重新创建了Cert.p12,程序开始工作。我不知道不工作的确切原因是什么,但我猜可能是Cert.p12文件损坏

谢谢大家的帮助。

未知\u ca:

接收到有效的证书链或部分链,但证书未被接受,因为找不到CA证书或无法与已知的受信任CA匹配。此消息始终是致命的

您可能需要将证书添加到jre的cacerts文件(通常位于lib/security下)。有关更多信息,请查看的文档及其-import选项

通过进一步研究cacerts文件和keytool,您可能会找到一个如何做到这一点的示例。

也有同样的问题

导入到IE/导出时使用“包含所有证书”解决此问题。

您所说的“包含所有证书”是什么意思?这是什么地方吗?找不到它:(