Skip to content

Commit

Permalink
removing disbale-verification function
Browse files Browse the repository at this point in the history
Signed-off-by: Shekhar Saxena <[email protected]>
  • Loading branch information
shekhar316 committed Dec 16, 2024
1 parent 69abe0b commit 68c0ee3
Showing 1 changed file with 0 additions and 26 deletions.
26 changes: 0 additions & 26 deletions src/main/java/com/autotune/utils/HttpUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,32 +91,6 @@ private static String getDataFromConnection(HttpURLConnection connection) throws
return response.toString();
}

public static void disableSSLVerification() {
TrustManager[] dummyTrustManager = new TrustManager[]{new X509TrustManager() {
public X509Certificate[] getAcceptedIssuers() {
return null;
}

public void checkClientTrusted(X509Certificate[] certs, String authType) { }

public void checkServerTrusted(X509Certificate[] certs, String authType) { }
}};

HostnameVerifier allHostsValid = (hostname, session) -> true;

SSLContext sslContext = null;
try {
sslContext = SSLContext.getInstance("TLSv1.2");
sslContext.init(null, dummyTrustManager, new java.security.SecureRandom());
} catch (NoSuchAlgorithmException | KeyManagementException e) {
e.printStackTrace();
}

assert sslContext != null;
HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory());
HttpsURLConnection.setDefaultHostnameVerifier(allHostsValid);
}

public static String postRequest(URL url, String content) {
try {
URLConnection connection = url.openConnection();
Expand Down

0 comments on commit 68c0ee3

Please sign in to comment.