Skip to content

Commit 77e436c

Browse files
authored
Handle the STRICT host name verifier explicitly (CodeQL java/missing-case-in-switch) (#244)
AsyncHttpClientProvider switched on the HostnameVerifier option but only had a case for ALLOW_ALL, relying on a pre-initialised DefaultHostnameVerifier to cover STRICT. Give the switch a default branch that assigns the strict verifier, the same shape already used by SyncHttpClientProvider. Behaviour is unchanged - STRICT still maps to DefaultHostnameVerifier - but the switch now covers every enum value and the two client providers are consistent.
1 parent 5f436d0 commit 77e436c

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

commons/http-framework/client-apache-async/src/main/java/org/forgerock/http/apache/async/AsyncHttpClientProvider.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* information: "Portions Copyright [year] [name of copyright owner]".
1313
*
1414
* Copyright 2015 ForgeRock AS.
15+
* Portions Copyrighted 2026 3A Systems, LLC
1516
*/
1617

1718
package org.forgerock.http.apache.async;
@@ -128,11 +129,15 @@ public HttpClient newHttpClient(final Options options) throws HttpApplicationExc
128129
throw new HttpApplicationException("Can't create SSL Context", e);
129130
}
130131

131-
HostnameVerifier verifier = new DefaultHostnameVerifier();
132+
final HostnameVerifier verifier;
132133
switch (options.get(OPTION_HOSTNAME_VERIFIER)) {
133134
case ALLOW_ALL:
134135
verifier = NoopHostnameVerifier.INSTANCE;
135136
break;
137+
default:
138+
// STRICT (and any future policy) uses strict host name verification.
139+
verifier = new DefaultHostnameVerifier();
140+
break;
136141
}
137142

138143
List<String> protocols = options.get(OPTION_SSL_ENABLED_PROTOCOLS);

0 commit comments

Comments
 (0)