JavaFX WebView can't load certain sites

后端 未结 1 1527
生来不讨喜
生来不讨喜 2020-12-17 04:44

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 l

相关标签:
1条回答
  • 2020-12-17 04:47

    Reason is java.lang.Throwable: SSL handshake failed

    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());
    

    There is also post, probably about similar case: JavaFx Webview JDK 8 can not load self signed certificate

    How do i know that it was 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());
                 ...
    

    also adding add -Djavax.net.debug=all to VMOption shows

    URL-Loader-1, handling exception: javax.net.ssl.SSLHandshakeException:

    sun.security.validator.ValidatorException: PKIX path building failed:

    sun.security.provider.certpath.SunCertPathBuilderException:

    unable to find valid certification path to requested target

    0 讨论(0)
提交回复
热议问题