InstallCert.java
這狀況挺奇怪的,運作已經半年以上的突然出了以下Exception:
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException:
PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderExce
ption: unable to find valid certification path to requested target
at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1937)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:302)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:296)
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.
java:1478)
at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.jav
a:212)
at sun.security.ssl.Handshaker.processLoop(Handshaker.java:957)
at sun.security.ssl.Handshaker.process_record(Handshaker.java:892)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1050)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.
java:1363)
出問題的地方在於我要連結一個https的路徑取回資料,參考解法步驟如下:
- 將上述連結InstallCert.java 的檔案拿回來存成InstallCert.java
- 切換到存放InstallCert.java的路徑,使用javac編譯成.class
- cmd:java InstallCert [your target SSL domain]
執行第一次的時候會有錯誤。再執行一次就可以(總共執行兩次) - 將產生出來的jssecacerts檔案複製到 $JAVA_HOME/jre/lib/secirity
- restart your service(ex:tomcat)