使用p12文件从Java服务器尝试Apple推送通知时,出现错误。我的p12文件或我的Java代码有问题吗?
run:
@:theodore nonis
C=IN, CN=Apple Development IOS Push Services: com.ducont.myPushApp, UID=com.ducont.myPushApp
theodore nonis
ok
init Stores...
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: No trusted certificate found
at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:174)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1591)
at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:187)
at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:181)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:975)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:123)
at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:516)
at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Handshaker.java:454)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:884)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1096)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1123)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1107)
at javatest.Main.APNSender(Main.java:88)
at javatest.Main.main(Main.java:114)
Caused by: sun.security.validator.ValidatorException: No trusted certificate found
at sun.security.validator.SimpleValidator.buildTrustedChain(SimpleValidator.java:304)
at sun.security.validator.SimpleValidator.engineValidate(SimpleValidator.java:107)
at sun.security.validator.Validator.validate(Validator.java:218)
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:126)
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:209)
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:249)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:954)
... 9 more
BUILD SUCCESSFUL (total time: 2 seconds)
答案 0 :(得分:0)
这可能是由java 1.9引起的,切换到java 1.8可能会解决您的问题。
答案 1 :(得分:0)
对于Windows,请尝试以下步骤:
从这里https://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html
下载jar将local_policy.jar和US_export_policy.jar复制到$ JAVA_HOME / jre / lib / security(注意:这些jar已存在,因此您必须覆盖它们)。
然后重新启动应用程序以摆脱此异常。
答案 2 :(得分:-2)