JavaFX WebView无法加载某些站点 [英] JavaFX WebView can't load certain sites
问题描述
我正在尝试使用JavaFX的WebView加载此网站,但我得到的只是一个空白屏幕。 WebView在其他网站上运行得非常好;它在ACID3上获得100/100并加载其他HTTPS站点而没有任何问题。
I'm trying to use JavaFX's WebView to load this site, but all I get is a blank screen. The WebView is working perfectly fine on other sites; it gets 100/100 on ACID3 and loads other HTTPS sites without any problems whatsoever.
我也找不到任何特别错误的网站。它具有由适当的CA签署的正确,未过期的证书,并且SSL实验室报告 B级。我尝试了所有主流浏览器,没有人报告任何证书或SSL相关问题;该网站对所有网站都提供了优惠。
I can't find anything particularly wrong with the site either. It has a proper, non-expired certificate signed by proper CA, and SSL Labs report a B grade. I tried all the major browsers on it and none report any certificate or SSL related issues; the site renders fine on all of them.
任何帮助都将不胜感激。即使是一个简单的是的网站也为我而破坏或这里没有问题会有很大的帮助。
Any help would be greatly appreciated. Even a simple "yeah the site's broken for me too" or "no problems here" would help a lot.
我正在使用Java SDK 1.8.0_45-b14 Windows 8.1 64位。
I'm using Java SDK 1.8.0_45-b14 on Windows 8.1 64-bit.
推荐答案
原因是 java.lang.Throwable:SSL握手失败
一个解决方案可以是:来自这篇文章 https: //stackoverflow.com/a/5671038/1032167 :
One solution can be: from this post 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无法加载自签名证书
There is also post, probably about similar case: JavaFx Webview JDK 8 can not load self signed certificate
我怎么知道它是 SSL握手失败
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显示
also adding add -Djavax.net.debug=all
to VMOption shows
URL-Loader-1,处理异常:javax.net.ssl.SSLHandshakeException:
URL-Loader-1, handling exception: javax.net.ssl.SSLHandshakeException:
sun.security.validator.Va lidatorException:PKIX路径构建失败:
sun.security.validator.ValidatorException: PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException:
sun.security.provider.certpath.SunCertPathBuilderException:
无法找到请求目标的有效证书路径
unable to find valid certification path to requested target
这篇关于JavaFX WebView无法加载某些站点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!