Skip to content

Commit

Permalink
Remove unused method
Browse files Browse the repository at this point in the history
  • Loading branch information
koppor committed Sep 7, 2024
1 parent e801f41 commit 9fd88ed
Showing 1 changed file with 0 additions and 48 deletions.
48 changes: 0 additions & 48 deletions src/main/java/org/jabref/logic/net/URLDownload.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,54 +91,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
* <p>
* 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...).
* <p>
* 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
Expand Down

0 comments on commit 9fd88ed

Please sign in to comment.