Hello,
I create a webview and request to load the page.
With "http: //" everything works, but with "https: //" it displays an error
java.lang.Throwable: Too many redirects
The code is simple:
public void loadUrl(String url) { Platform.runLater(new Runnable() { @Override public void run() { webEngine.load(url); } }); } Tried to save cookies:
public void loadUrl(String url) { Platform.runLater(new Runnable() { @Override public void run() { String tmp = toURL(url); if (tmp == null) { tmp = toURL("http://" + url); } URI uri = URI.create(tmp); Map<String, List<String>> headers = new LinkedHashMap<String, List<String>>(); headers.put("Set-Cookie", Arrays.asList("name=value")); try { CookieHandler.getDefault() .put(uri, headers); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } webEngine.load(tmp); } }); } I tried to remove the connection protection:
public void loadUrl(String url) { TrustManager[] trustAllCerts = new TrustManager[] {new X509TrustManager() { public java.security.cert.X509Certificate[] getAcceptedIssuers() { return null; } public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) {} public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) {} }}; // Install the all-trusting trust manager try { SSLContext sc = SSLContext.getInstance("SSL"); sc.init(null, trustAllCerts, new java.security.SecureRandom()); HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); } catch (GeneralSecurityException e) { } Platform.runLater(new Runnable() { @Override public void run() { webEngine.load(tmp); } }); } But nothing happened.
Update
The fact is that it is not clear why the error.
In theory, ordinary cookies work. Perhaps some secure https cookies do not work.
If the error is a secure connection, then the error should be different, the type could not establish a connection.
Perhaps some problems with Kaspersky, with his certificates which he substitutes. But turned it off and still the error associated with redirects.
Perhaps there is a way to track more error. Where are redirects, because of what redirects.
The strangest thing is that the component is standard, but how many were looking for did not find a solution.