source: https://wallacenotebook.blogspot.com/2019/07/javasslhttps-pkixunable-to-find-valid.html **Java http client 訪問SSL(https)網站遇到 PKIX:unable to find valid certification path to requested target問題** 發生原因: Java訪問SSL(https)網站時,需要從JDK的KeyStore取出相對應可信任憑證進行驗證,如果從預設或另外指定的KeyStore無法找到憑證就會出現此錯誤。 另外Java的KeyStore並非windows的系統的憑證管理,因此無法使用windows安裝的憑證。 解決方法: 使用java keytool(keytool位於java的bin目錄下)將SSL憑證匯入到java預設KeyStore即可 1. 下載網站憑證(以chrome為例)   2. 匯入KeyStore 使用系統管理員身分開啟"命令提示字元", cd 到jre下的lib/security目錄(注意JDK目錄裡也有一個jre目錄,要安裝到執行java程式時使用的jre,若不知道就全安裝) keytool -import -file you_certificate_file -keystore cacerts -alias your_certificate_name(預設密碼changeit) 3. 查看憑證是否安裝成功 keytool -v -list -keystore cacerts -alias your_certificate_name
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up