22
22
import java .util .List ;
23
23
import java .util .stream .Collectors ;
24
24
25
+ import javax .net .ssl .HostnameVerifier ;
25
26
import javax .net .ssl .SSLContext ;
26
27
27
28
import org .springframework .data .elasticsearch .client .ClientConfiguration .ClientConfigurationBuilderWithRequiredEndpoint ;
38
39
* @author Mark Paluch
39
40
* @author Peter-Josef Meisch
40
41
* @author Huw Ayling-Miller
42
+ * @author Henrique Amaral
41
43
* @since 3.2
42
44
*/
43
45
class ClientConfigurationBuilder
@@ -47,6 +49,7 @@ class ClientConfigurationBuilder
47
49
private HttpHeaders headers = HttpHeaders .EMPTY ;
48
50
private boolean useSsl ;
49
51
private @ Nullable SSLContext sslContext ;
52
+ private @ Nullable HostnameVerifier hostnameVerifier ;
50
53
private Duration connectTimeout = Duration .ofSeconds (10 );
51
54
private Duration soTimeout = Duration .ofSeconds (5 );
52
55
private String username ;
@@ -105,6 +108,22 @@ public TerminalClientConfigurationBuilder usingSsl(SSLContext sslContext) {
105
108
return this ;
106
109
}
107
110
111
+ /*
112
+ * (non-Javadoc)
113
+ * @see org.springframework.data.elasticsearch.client.ClientConfiguration.MaybeSecureClientConfigurationBuilder#usingSsl(javax.net.ssl.SSLContext, javax.net.ssl.HostnameVerifier)
114
+ */
115
+ @ Override
116
+ public TerminalClientConfigurationBuilder usingSsl (SSLContext sslContext , HostnameVerifier hostnameVerifier ) {
117
+
118
+ Assert .notNull (sslContext , "SSL Context must not be null" );
119
+ Assert .notNull (hostnameVerifier , "Host Name Verifier must not be null" );
120
+
121
+ this .useSsl = true ;
122
+ this .sslContext = sslContext ;
123
+ this .hostnameVerifier = hostnameVerifier ;
124
+ return this ;
125
+ }
126
+
108
127
/*
109
128
* (non-Javadoc)
110
129
* @see org.springframework.data.elasticsearch.client.ClientConfiguration.TerminalClientConfigurationBuilder#withDefaultHeaders(org.springframework.http.HttpHeaders)
@@ -181,7 +200,7 @@ public ClientConfiguration build() {
181
200
}
182
201
183
202
return new DefaultClientConfiguration (this .hosts , this .headers , this .useSsl , this .sslContext , this .soTimeout ,
184
- this .connectTimeout , this .pathPrefix );
203
+ this .connectTimeout , this .pathPrefix , this . hostnameVerifier );
185
204
}
186
205
187
206
private static InetSocketAddress parse (String hostAndPort ) {
0 commit comments