Skip to content

Commit

Permalink
Use NoopHostname verifier in IAST Apache client
Browse files Browse the repository at this point in the history
  • Loading branch information
IshikaDawda committed Dec 16, 2024
1 parent 49e7ece commit a073771
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
import org.apache.http.conn.ssl.DefaultHostnameVerifier;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.entity.StringEntity;
Expand Down Expand Up @@ -98,7 +99,7 @@ public ApacheHttpClientWrapper(int requestTimeoutInMillis) {
.disableCookieManagement()
.disableAuthCaching()
.disableConnectionState()
.setSSLHostnameVerifier(new DefaultHostnameVerifier())
.setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE)
.setDefaultRequestConfig(RequestConfig.custom()
// Timeout in millis until a connection is established.
.setConnectTimeout(requestTimeoutInMillis)
Expand Down Expand Up @@ -137,7 +138,7 @@ private static PoolingHttpClientConnectionManager createHttpClientConnectionMana
RegistryBuilder.<ConnectionSocketFactory>create()
.register("http", PlainConnectionSocketFactory.getSocketFactory())
.register("https", sslContext != null ?
new SSLConnectionSocketFactory(sslContext) : SSLConnectionSocketFactory.getSocketFactory())
new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE) : SSLConnectionSocketFactory.getSocketFactory())
.build());

// We only allow one connection at a time to the backend.
Expand Down

0 comments on commit a073771

Please sign in to comment.