Skip to content

Commit b82ea06

Browse files
Use standard TLS when downloading the database from an HTTP URL. (#6163) (#6167)
(cherry picked from commit b0386a5) Signed-off-by: David Venable <dlv@amazon.com> Co-authored-by: David Venable <dlv@amazon.com>
1 parent fa21a60 commit b82ea06

2 files changed

Lines changed: 0 additions & 44 deletions

File tree

data-prepper-plugins/geoip-processor/src/main/java/org/opensearch/dataprepper/plugins/geoip/extension/databasedownload/DBSource.java

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -5,50 +5,7 @@
55

66
package org.opensearch.dataprepper.plugins.geoip.extension.databasedownload;
77

8-
import javax.net.ssl.HostnameVerifier;
9-
import javax.net.ssl.HttpsURLConnection;
10-
import javax.net.ssl.SSLContext;
11-
import javax.net.ssl.SSLSession;
12-
import javax.net.ssl.TrustManager;
13-
import javax.net.ssl.X509TrustManager;
14-
import java.security.KeyManagementException;
15-
import java.security.NoSuchAlgorithmException;
16-
import java.security.SecureRandom;
17-
import java.security.cert.CertificateException;
18-
import java.security.cert.X509Certificate;
19-
208
public interface DBSource {
219
String MAXMIND_DATABASE_EXTENSION = ".mmdb";
2210
void initiateDownload() throws Exception;
23-
24-
/**
25-
* initiateSSL
26-
* @throws NoSuchAlgorithmException NoSuchAlgorithmException
27-
* @throws KeyManagementException KeyManagementException
28-
*/
29-
default void initiateSSL() throws NoSuchAlgorithmException, KeyManagementException {
30-
final TrustManager[] trustAllCerts = new TrustManager[]{
31-
new X509TrustManager() {
32-
public X509Certificate[] getAcceptedIssuers() {
33-
return null;
34-
}
35-
public void checkServerTrusted(X509Certificate[] certs, String authType) throws CertificateException {
36-
return;
37-
}
38-
public void checkClientTrusted(X509Certificate[] certs, String authType) throws CertificateException {
39-
return;
40-
}
41-
}
42-
};
43-
44-
final SSLContext sc = SSLContext.getInstance("TLS");
45-
sc.init(null, trustAllCerts, new SecureRandom());
46-
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
47-
final HostnameVerifier hostnameVerifier = new HostnameVerifier() {
48-
public boolean verify(String urlHostName, SSLSession session) {
49-
return true;
50-
}
51-
};
52-
HttpsURLConnection.setDefaultHostnameVerifier(hostnameVerifier);
53-
}
5411
}

data-prepper-plugins/geoip-processor/src/main/java/org/opensearch/dataprepper/plugins/geoip/extension/databasedownload/HttpDBDownloadService.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ public void initiateDownload() {
5353
for (final String key: databasePaths) {
5454
geoIPFileManager.createDirectoryIfNotExist(tarDir);
5555
try {
56-
initiateSSL();
5756
buildRequestAndDownloadFile(maxMindDatabaseConfig.getDatabasePaths().get(key), downloadTarFilepath);
5857
final File tarFile = decompressAndgetTarFile(tarDir, downloadTarFilepath);
5958
unTarFile(tarFile, new File(destinationDirectory), key);

0 commit comments

Comments
 (0)