天天看點

使用Java消費API的一個錯誤消息PKIX path building failed以及解決方案

我使用Java代碼消費一個網站的Restful API,遇到如下錯誤:

PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

隻需要将該網站的證書從浏覽器導出,然後再倒入本地JDK的keystore即可。

具體做法如下:

浏覽器裡導出網站證書:

存儲成base 64格式:

檢查下Eclipse裡使用的JRE的位置:

到該位置下,用軟體Portecle打開keystore檔案:

繼續閱讀