【发布时间】:2016-03-08 19:34:09
【问题描述】:
问题
编辑:这个问题的第一个版本给人的印象是我的问题与 Maven 有关。我重新措辞以更加关注 JDK。
我在尝试使用 Java 联系任何启用 SSL 的服务时收到 sun.security.provider.certpath.SunCertPathBuilderException: PKIX path building failed。对其他相关问题的回答并没有阻止我的错误。
任何 Maven 任务都会出现该错误,如下所示...
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.5:clean (default-clean) on project foundation-ddl: Execution default-clean of goal org.apache.maven.plugins:maven-clean-plugin:2.5:clean failed: Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its dependencies could not be resolved: Failed to collect dependencies at org.apache.maven.plugins:maven-clean-plugin:jar:2.5 -> org.apache.maven:maven-plugin-api:jar:2.0.6: Failed to read artifact descriptor for org.apache.maven:maven-plugin-api:jar:2.0.6: Could not transfer artifact org.apache.maven:maven-plugin-api:pom:2.0.6 from/to example (https://example.com/artifactory/repo/): sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target -> [Help 1]
...或者如果我执行一个与 SSL 服务联系的 jar
$ java -jar atlassian-bamboo-agent-installer-5.9.7.jar http://...
INFO | jvm 1 | 2016/03/09 10:59:21 | 2016-03-09 10:59:21,381 FATAL [WrapperSimpleAppMain] [AgentBootstrap] Exiting due to fatal exception.
INFO | jvm 1 | 2016/03/09 10:59:21 | javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
INFO | jvm 1 | 2016/03/09 10:59:21 | at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
INFO | jvm 1 | 2016/03/09 10:59:21 | at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1949)
INFO | jvm 1 | 2016/03/09 10:59:21 | at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:302)
INFO | jvm 1 | 2016/03/09 10:59:21 | at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:296)
INFO | jvm 1 | 2016/03/09 10:59:21 | at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1509)
INFO | jvm 1 | 2016/03/09 10:59:21 | at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:216)
INFO | jvm 1 | 2016/03/09 10:59:21 | at sun.security.ssl.Handshaker.processLoop(Handshaker.java:979)
INFO | jvm 1 | 2016/03/09 10:59:21 | at sun.security.ssl.Handshaker.process_record(Handshaker.java:914)
INFO | jvm 1 | 2016/03/09 10:59:21 | at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1062)
INFO | jvm 1 | 2016/03/09 10:59:21 | at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375)
INFO | jvm 1 | 2016/03/09 10:59:21 | at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1403)
INFO | jvm 1 | 2016/03/09 10:59:21 | at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1387)
INFO | jvm 1 | 2016/03/09 10:59:21 | at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:535)
INFO | jvm 1 | 2016/03/09 10:59:21 | at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:403)
INFO | jvm 1 | 2016/03/09 10:59:21 | at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:177)
INFO | jvm 1 | 2016/03/09 10:59:21 | at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:304)
INFO | jvm 1 | 2016/03/09 10:59:21 | at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:611)
INFO | jvm 1 | 2016/03/09 10:59:21 | at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:446)
INFO | jvm 1 | 2016/03/09 10:59:21 | at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:863)
INFO | jvm 1 | 2016/03/09 10:59:21 | at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
INFO | jvm 1 | 2016/03/09 10:59:21 | at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:106)
INFO | jvm 1 | 2016/03/09 10:59:21 | at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:57)
INFO | jvm 1 | 2016/03/09 10:59:21 | at com.atlassian.bamboo.agent.bootstrap.AgentContext.initFingerprint(AgentContext.java:118)
INFO | jvm 1 | 2016/03/09 10:59:21 | at com.atlassian.bamboo.agent.bootstrap.AgentContext.initServerSession(AgentContext.java:103)
INFO | jvm 1 | 2016/03/09 10:59:21 | at com.atlassian.bamboo.agent.bootstrap.AgentContext.run(AgentContext.java:94)
INFO | jvm 1 | 2016/03/09 10:59:21 | at com.atlassian.bamboo.agent.bootstrap.AgentBootstrap.run(AgentBootstrap.java:95)
INFO | jvm 1 | 2016/03/09 10:59:21 | at com.atlassian.bamboo.agent.bootstrap.AgentBootstrap.main(AgentBootstrap.java:41)
INFO | jvm 1 | 2016/03/09 10:59:21 | at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
INFO | jvm 1 | 2016/03/09 10:59:21 | at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
INFO | jvm 1 | 2016/03/09 10:59:21 | at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
INFO | jvm 1 | 2016/03/09 10:59:21 | at java.lang.reflect.Method.invoke(Method.java:498)
INFO | jvm 1 | 2016/03/09 10:59:21 | at org.tanukisoftware.wrapper.WrapperSimpleApp.run(WrapperSimpleApp.java:240)
INFO | jvm 1 | 2016/03/09 10:59:21 | at java.lang.Thread.run(Thread.java:745)
INFO | jvm 1 | 2016/03/09 10:59:21 | Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
我尝试了什么
- 这些答案是:Resolving javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed Error?
- 我使用InstallCert 访问了出现异常的主机,并成功将证书添加到了信任库。为了进行验证,IntelliCert 打印了
No errors, certificate is already trusted,但 这并没有阻止错误。 - 步骤 2 并没有阻止错误的事实让我认为(在 Maven 案例中)Maven 使用了不同的信任库。我使用了“How to change maven java home”的答案来确保 Maven 至少使用了我正在考虑的同一个 Java 实例(在 Oracle JDK 1.8 中)。这并没有改变任何东西,所以我现在正在查看 JDK。
解决此问题的众所周知的方法似乎不起作用。 如何停止错误、修复 JDK 并最终再次使用启用 SSL 的服务?
【问题讨论】:
-
这个错误是在更改JDK版本之后出现的吗?
-
我没有在我的系统上更改我的 JDK 版本,如果这就是你要问的。您是指在某处更改文件中的 JDK 版本吗?
-
是的,我只是好奇,因为你提到它以前可以工作。