|
17 | 17 |
|
18 | 18 | import static org.asynchttpclient.AsyncHttpClientConfigDefaults.*;
|
19 | 19 |
|
20 |
| -import org.asynchttpclient.date.TimeConverter; |
21 |
| -import org.asynchttpclient.filter.IOExceptionFilter; |
22 |
| -import org.asynchttpclient.filter.RequestFilter; |
23 |
| -import org.asynchttpclient.filter.ResponseFilter; |
24 |
| -import org.asynchttpclient.util.ProxyUtils; |
25 |
| - |
26 |
| -import javax.net.ssl.HostnameVerifier; |
27 |
| -import javax.net.ssl.SSLContext; |
28 |
| - |
29 | 20 | import java.io.IOException;
|
30 | 21 | import java.io.InputStream;
|
31 | 22 | import java.util.Collections;
|
|
35 | 26 | import java.util.concurrent.ExecutorService;
|
36 | 27 | import java.util.concurrent.Executors;
|
37 | 28 |
|
| 29 | +import javax.net.ssl.HostnameVerifier; |
| 30 | +import javax.net.ssl.SSLContext; |
| 31 | + |
| 32 | +import org.asynchttpclient.date.TimeConverter; |
| 33 | +import org.asynchttpclient.filter.IOExceptionFilter; |
| 34 | +import org.asynchttpclient.filter.RequestFilter; |
| 35 | +import org.asynchttpclient.filter.ResponseFilter; |
| 36 | +import org.asynchttpclient.util.DefaultHostnameVerifier; |
| 37 | +import org.asynchttpclient.util.ProxyUtils; |
| 38 | + |
38 | 39 | /**
|
39 | 40 | * Configuration class to use with a {@link AsyncHttpClient}. System property can be also used to configure this
|
40 | 41 | * object default behavior by doing:
|
@@ -538,7 +539,7 @@ public static class Builder {
|
538 | 539 | private int pooledConnectionIdleTimeout = defaultPooledConnectionIdleTimeout();
|
539 | 540 | private int connectionTTL = defaultConnectionTTL();
|
540 | 541 | private SSLContext sslContext;
|
541 |
| - private HostnameVerifier hostnameVerifier = defaultHostnameVerifier(); |
| 542 | + private HostnameVerifier hostnameVerifier; |
542 | 543 | private boolean acceptAnyCertificate = defaultAcceptAnyCertificate();
|
543 | 544 | private boolean followRedirect = defaultFollowRedirect();
|
544 | 545 | private int maxRedirects = defaultMaxRedirects();
|
@@ -1082,17 +1083,19 @@ public Builder(AsyncHttpClientConfig prototype) {
|
1082 | 1083 | */
|
1083 | 1084 | public AsyncHttpClientConfig build() {
|
1084 | 1085 |
|
1085 |
| - if (proxyServerSelector == null && useProxySelector) { |
| 1086 | + if (proxyServerSelector == null && useProxySelector) |
1086 | 1087 | proxyServerSelector = ProxyUtils.getJdkDefaultProxyServerSelector();
|
1087 |
| - } |
1088 | 1088 |
|
1089 |
| - if (proxyServerSelector == null && useProxyProperties) { |
| 1089 | + if (proxyServerSelector == null && useProxyProperties) |
1090 | 1090 | proxyServerSelector = ProxyUtils.createProxyServerSelector(System.getProperties());
|
1091 |
| - } |
1092 | 1091 |
|
1093 |
| - if (proxyServerSelector == null) { |
| 1092 | + if (proxyServerSelector == null) |
1094 | 1093 | proxyServerSelector = ProxyServerSelector.NO_PROXY_SELECTOR;
|
1095 |
| - } |
| 1094 | + |
| 1095 | + if (acceptAnyCertificate) |
| 1096 | + hostnameVerifier = null; |
| 1097 | + else if (hostnameVerifier == null) |
| 1098 | + hostnameVerifier = new DefaultHostnameVerifier(); |
1096 | 1099 |
|
1097 | 1100 | return new AsyncHttpClientConfig(connectionTimeout,//
|
1098 | 1101 | maxConnections,//
|
|
0 commit comments