原因是java.lang.Throwable: SSL handshake failed
一種解決方案可以是:從這篇文章https://stackoverflow.com/a/5671038/1032167:
TrustManager trm = new X509TrustManager() {
public X509Certificate[] getAcceptedIssuers() {return null;}
public void checkClientTrusted(X509Certificate[] certs, String authType) {}
public void checkServerTrusted(X509Certificate[] certs, String authType) {}
};
SSLContext sc = SSLContext.getInstance("SSL");
sc.init(null, new TrustManager[] { trm }, null);
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
另外也張貼,大概類似的案件:JavaFx Webview JDK 8 can not load self signed certificate
我怎麼知道它是SSL handshake failed
webView.getEngine().getLoadWorker().stateProperty().addListener(
new ChangeListener<Worker.State>() {
public void changed(ObservableValue ov,
Worker.State oldState, Worker.State newState) {
System.out.println(webView.getEngine().getLoadWorker().exceptionProperty());
...
也只需添加-Djavax.net.debug=all
到VMOption顯示
URL-裝載機-1,處理異常:javax.net.ssl.SSLHandshakeException:
sun.security.validator.ValidatorException:PKIX路徑建設失敗:
sun.security.provider.certpath.SunCertPathBuilderException:
無法找到請求的目標的有效證書路徑