簡體   English   中英

Oracle JDK 上仍然存在 PKIX 路徑構建失敗錯誤

[英]PKIX path building failed error persists on Oracle JDK

問題

編輯:這個問題的第一個版本給人的印象是我的問題與 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

我試過的

  1. 這些答案是: Resolving javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed Error?
  2. 我使用InstallCert訪問了出現異常的主機,並且我成功地將證書添加到了信任存儲中。 為了驗證,IntelliCert 打印No errors, certificate is already trusted ,但這並沒有阻止錯誤。
  3. 事實上,步驟 2 並沒有阻止錯誤讓我認為(在 Maven 的情況下)Maven 使用的是不同的信任庫。 我使用了“ 如何更改 maven java home ”的答案來確保 Maven 至少使用了我正在考慮的相同 Java 實例(在 Oracle JDK 1.8 中)。 這沒有改變任何東西,所以我現在正在研究 JDK。

解決此問題的眾所周知的方法似乎不起作用。 如何停止錯誤、修復我的 JDK 並最終再次使用啟用 SSL 的服務?

經過徒勞的調查,我最終清除並重新安裝了 JDK,從而解決了問題。 JDK 的版本沒有改變。 對於那些通過谷歌訪問此問題的頁面的人,只需這樣做,就可以避免恐懼。

您應該檢查您正在使用的 JDK 版本並將中間證書以及 CA(如果它是自簽名或內部簽名)安裝到 maven 正在使用的 JDK 中。 我認為這可以解決問題。

刪除 ~/.m2/repository 不應該是原因。 確保最近沒有更改證書。

您甚至可以使用以下 Maven 選項來定位您的信任庫和密鑰庫。

MAVEN_OPTS="-Xmx512m -Djavax.net.ssl.trustStore=trust.jks \
                     -Djavax.net.ssl.trustStorePassword=  \
                     -Djavax.net.ssl.keyStore=/home/directory/mycertificate.p12 \
                     -Djavax.net.ssl.keyStoreType=pkcs12 \
                     -Djavax.net.ssl.keyStorePassword=XXXXXX"

請參考以下 URL,這是 Maven SSL 配置的好指南

https://maven.apache.org/guides/mini/guide-repository-ssl.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM