Revision: 6142 http://sourceforge.net/p/jump-pilot/code/6142 Author: michaudm Date: 2019-02-25 08:13:55 +0000 (Mon, 25 Feb 2019) Log Message: ----------- Fix URLConnectionProvider
Modified Paths: -------------- core/trunk/src/org/openjump/util/URLConnectionProvider.java Modified: core/trunk/src/org/openjump/util/URLConnectionProvider.java =================================================================== --- core/trunk/src/org/openjump/util/URLConnectionProvider.java 2019-02-24 17:14:14 UTC (rev 6141) +++ core/trunk/src/org/openjump/util/URLConnectionProvider.java 2019-02-25 08:13:55 UTC (rev 6142) @@ -54,10 +54,11 @@ if (!protocol.equals("https")) return url.openConnection(); URLConnection connection; try { + setTrustOption(false, null); connection = url.openConnection(); connection.connect(); // try to connect return connection; // can connect - } catch(IOException e) { + } catch(IOException|KeyManagementException|NoSuchAlgorithmException e) { String baseURL = new URL(url.getProtocol(), url.getHost(), url.getPort(), url.getPath()).toString(); if (authorizedURL.contains(baseURL) || acceptConnection(url)) { try { @@ -64,7 +65,7 @@ setTrustOption(true, url); connection = url.openConnection(); authorizedURL.add(baseURL); - setTrustOption(false, url); + //setTrustOption(false, null); return connection; } catch(KeyManagementException|NoSuchAlgorithmException ex2) { throw new IOException(ex2); @@ -98,10 +99,12 @@ private void setTrustOption(boolean trust, URL url) throws KeyManagementException, NoSuchAlgorithmException { SSLContext sc = SSLContext.getInstance("SSL"); - if (trust || trustedURLs.contains(url)) { + if (trust || (url != null && trustedURLs.contains(url))) { + System.out.println("Set the trust manager to not check certificates"); sc.init(null, new TrustManager[]{trm}, null); trustedURLs.add(url); } else { + System.out.println("Set the trust manager to check certificates"); sc.init(null, null, null); } HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); _______________________________________________ Jump-pilot-devel mailing list Jump-pilot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel