简体   繁体   English

ValidatorException: 在 java 中找不到受信任的证书

[英]ValidatorException: No trusted certificate found in java

When trying Apple push notifications from a Java server using a p12 file, I get an error.使用 p12 文件从 Java 服务器尝试 Apple 推送通知时,出现错误。 Is there a problem with my p12 file or my Java code?我的 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)

这可能是由 java 1.9 引起的,切换到 java 1.8 可能会解决您的问题。

Try below steps for windows:对于 Windows,请尝试以下步骤:

Download jars from here https://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html从这里下载 jars https://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html

Copy local_policy.jar and US_export_policy.jar to the $JAVA_HOME/jre/lib/security (Note: these jars will be already there so you have to overwrite them).将 local_policy.jar 和 US_export_policy.jar 复制到 $JAVA_HOME/jre/lib/security(注意:这些 jar 文件已经存在,因此您必须覆盖它们)。

Then restart your application to get rid of this exception.然后重新启动您的应用程序以摆脱此异常。

This is certificate problem.这是证书问题。 There can be two solutions:可以有两种解决方案:

1 Use trusted certificate 1 使用可信证书

2 Disable certificate checking. 2 禁用证书检查。 For plain java code it can be done that way ( read here ).对于普通的 Java 代码,可以通过这种方式完成( 阅读此处)。

In p12 should be some possibility to set up TrustManages.在 p12 中应该可以设置 TrustManages。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 IPG支付网关.javax.net.ssl.SSLHandshakeException:sun.security.validator.ValidatorException:找不到可信证书 - IPG Payment Gateway.javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: No trusted certificate found 线程“主”javax.net.ssl.SSLHandshakeException 中的异常:sun.security.validator.ValidatorException:未找到受信任的证书 - Exception in thread "main" javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: No trusted certificate found java-trustStore的路径找不到可信证书错误 - java - path to trustStore No trusted certificate found error Docker Java应用程序-SSLHandshakeException /未找到可信证书 - Docker Java application - SSLHandshakeException / No trusted certificate found Java TLS套接字:找不到可信证书 - Java TLS socket : No trusted certificate found Gradle:找不到可信证书 - Gradle: No trusted certificate found Java notnoop,APNS在tomcat内部找不到可信证书 - Java notnoop,APNS No trusted certificate found from inside tomcat 未找到hdfs fsck /命令的受信任证书 - No trusted certificate found for hdfs fsck / command Spring 集成 SSL 连接上的“未找到受信任的证书” - “No trusted certificate found” on Spring Integration SSL Connection 受信任的证书条目不是受密码保护的Java - trusted certificate entries are not password-protected java
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM