|
13 | 13 | import static java.util.Optional.ofNullable; |
14 | 14 | import java.util.stream.Stream; |
15 | 15 |
|
| 16 | +import javax.net.ssl.HostnameVerifier; |
16 | 17 | import javax.net.ssl.KeyManagerFactory; |
17 | 18 | import javax.net.ssl.KeyStoreBuilderParameters; |
18 | 19 | import javax.net.ssl.SSLContext; |
| 20 | +import javax.net.ssl.SSLSession; |
19 | 21 | import javax.net.ssl.TrustManagerFactory; |
20 | 22 |
|
21 | 23 | import org.apache.hc.client5.http.classic.methods.HttpGet; |
@@ -117,6 +119,14 @@ private String absFile(String f) { |
117 | 119 | return new File(f).getAbsolutePath(); |
118 | 120 | } |
119 | 121 |
|
| 122 | + // Allow all hostnames for testing purposes |
| 123 | + HostnameVerifier allowAll = new HostnameVerifier() { |
| 124 | + @Override |
| 125 | + public boolean verify(String hostName, SSLSession session) { |
| 126 | + return true; |
| 127 | + } |
| 128 | + }; |
| 129 | + |
120 | 130 | @BeforeEach |
121 | 131 | @SneakyThrows |
122 | 132 | void setup() { |
@@ -170,8 +180,8 @@ void testHttpClient(String description, int expectedResponseCode, |
170 | 180 |
|
171 | 181 | assertNotNull(sslContext.getProvider()); |
172 | 182 |
|
173 | | - SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext, |
174 | | - new DefaultHostnameVerifier()); |
| 183 | + SSLConnectionSocketFactory sslsf = |
| 184 | + new SSLConnectionSocketFactory(sslContext, allowAll); |
175 | 185 |
|
176 | 186 | Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder |
177 | 187 | .<ConnectionSocketFactory>create().register("https", sslsf).build(); |
|
0 commit comments