From 4b633aacaafb3b17201ab537ff4b0bb2aa5c88f5 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Sat, 7 Sep 2024 17:00:46 +0200 Subject: [PATCH] Remove unused method (#11718) * Remove unused method * Fix imports * Remove imports --- .../org/jabref/logic/net/URLDownload.java | 53 ------------------- 1 file changed, 53 deletions(-) diff --git a/src/main/java/org/jabref/logic/net/URLDownload.java b/src/main/java/org/jabref/logic/net/URLDownload.java index db9e3b4d9f7..636448716bd 100644 --- a/src/main/java/org/jabref/logic/net/URLDownload.java +++ b/src/main/java/org/jabref/logic/net/URLDownload.java @@ -23,8 +23,6 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.StandardCopyOption; -import java.security.SecureRandom; -import java.security.cert.X509Certificate; import java.time.Duration; import java.util.Collections; import java.util.HashMap; @@ -34,10 +32,7 @@ import javax.net.ssl.HostnameVerifier; import javax.net.ssl.HttpsURLConnection; -import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSocketFactory; -import javax.net.ssl.TrustManager; -import javax.net.ssl.X509TrustManager; import org.jabref.http.dto.SimpleHttpResponse; import org.jabref.logic.importer.FetcherClientException; @@ -91,54 +86,6 @@ public URLDownload(URL source) { this.addHeader("User-Agent", URLDownload.USER_AGENT); } - /** - * Older java VMs does not automatically trust the zbMATH certificate. In this case the following exception is - * thrown: sun.security.validator.ValidatorException: PKIX path building failed: - * sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested - * target JM > 8u101 may trust the certificate by default according to http://stackoverflow.com/a/34111150/873661 - *

- * We will fix this issue by accepting all (!) certificates. This is ugly; but as JabRef does not rely on - * security-relevant information this is kind of OK (no, actually it is not...). - *

- * Taken from http://stackoverflow.com/a/6055903/873661 and https://stackoverflow.com/a/19542614/873661 - * - * @deprecated - */ - @Deprecated - public static void bypassSSLVerification() { - LOGGER.warn("Fix SSL exceptions by accepting ALL certificates"); - - // Create a trust manager that does not validate certificate chains - TrustManager[] trustAllCerts = {new X509TrustManager() { - @Override - public void checkClientTrusted(X509Certificate[] chain, String authType) { - } - - @Override - public void checkServerTrusted(X509Certificate[] chain, String authType) { - } - - @Override - public X509Certificate[] getAcceptedIssuers() { - return new X509Certificate[0]; - } - }}; - - try { - // Install all-trusting trust manager - SSLContext context = SSLContext.getInstance("TLS"); - context.init(null, trustAllCerts, new SecureRandom()); - HttpsURLConnection.setDefaultSSLSocketFactory(context.getSocketFactory()); - - // Install all-trusting host verifier - HostnameVerifier allHostsValid = (hostname, session) -> true; - HttpsURLConnection.setDefaultHostnameVerifier(allHostsValid); - } catch ( - Exception e) { - LOGGER.error("A problem occurred when bypassing SSL verification", e); - } - } - /** * @param socketFactory trust manager * @param verifier host verifier