准备环境
-Djavax.net.debug=all
代码
webView.getEngine().getLoadWorker().stateProperty().addListener(new ChangeListener<Worker.State>() {
@Override
public void changed(ObservableValue<? extends Worker.State> observable, Worker.State oldValue, Worker.State newValue) {
System.out.println(webView.getEngine().getLoadWorker().exceptionProperty());
}
});
TrustManager[] trustAllCerts = new TrustManager[] {new MyManager()};
// Install the all-trusting trust manager
SSLContext sc = null;
try {
sc = SSLContext.getInstance("SSL");
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
try {
sc.init(null, trustAllCerts, new java.security.SecureRandom());
} catch (KeyManagementException e) {
e.printStackTrace();
}
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
// Create all-trusting host name verifier
HostnameVerifier allHostsValid = new HostnameVerifier() {
public boolean verify(String hostname, SSLSession session) {
return true;
}
};
// Install the all-trusting host verifier
HttpsURLConnection.setDefaultHostnameVerifier(allHostsValid);
报错信息
javax.net.ssl|WARNING|17|Keep-Alive-Timer|2022-11-24 11:27:53.953 CST|SSLSocketImpl.java:500|SSLSocket duplex close failed (
"throwable" : {
java.net.SocketException: Socket is closed
at java.net.Socket.shutdownInput(Socket.java:1538)
at sun.security.ssl.BaseSSLSocketImpl.shutdownInput(BaseSSLSocketImpl.java:216)
at sun.security.ssl.SSLSocketImpl.shutdownInput(SSLSocketImpl.java:743)
at sun.security.ssl.SSLSocketImpl.bruteForceCloseInput(SSLSocketImpl.java:693)
at sun.security.ssl.SSLSocketImpl.duplexCloseOutput(SSLSocketImpl.java:553)
at sun.security.ssl.SSLSocketImpl.close(SSLSocketImpl.java:485)
at sun.net.www.http.HttpClient.closeServer(HttpClient.java:1053)
at sun.net.www.http.KeepAliveCache.run(KeepAliveCache.java:199)
at java.lang.Thread.run(Thread.java:748)}
)