|
70 | 70 | import java.net.URI;
|
71 | 71 | import java.net.URISyntaxException;
|
72 | 72 | import java.nio.charset.StandardCharsets;
|
| 73 | +import java.security.cert.CertificateException; |
| 74 | +import java.security.cert.X509Certificate; |
73 | 75 | import java.util.ArrayList;
|
74 | 76 | import java.util.Collections;
|
75 | 77 | import java.util.Comparator;
|
|
101 | 103 | import org.apache.http.client.methods.HttpPut;
|
102 | 104 | import org.apache.http.client.methods.HttpRequestBase;
|
103 | 105 | import org.apache.http.client.protocol.HttpClientContext;
|
| 106 | +import org.apache.http.conn.ssl.NoopHostnameVerifier; |
104 | 107 | import org.apache.http.entity.ContentType;
|
105 | 108 | import org.apache.http.entity.StringEntity;
|
106 | 109 | import org.apache.http.impl.auth.BasicScheme;
|
|
109 | 112 | import org.apache.http.impl.client.CloseableHttpClient;
|
110 | 113 | import org.apache.http.impl.client.HttpClientBuilder;
|
111 | 114 | import org.apache.http.message.BasicNameValuePair;
|
| 115 | +import org.apache.http.ssl.SSLContextBuilder; |
| 116 | +import org.apache.http.ssl.TrustStrategy; |
112 | 117 | import org.apache.http.util.EntityUtils;
|
113 | 118 |
|
| 119 | +import javax.net.ssl.SSLContext; |
| 120 | + |
114 | 121 | import static java.util.Objects.requireNonNull;
|
115 | 122 |
|
116 | 123 | /**
|
@@ -823,6 +830,19 @@ private CloseableHttpClient getHttpClient(final HttpRequestBase request) {
|
823 | 830 |
|
824 | 831 | final String host = getMethodHost(request);
|
825 | 832 |
|
| 833 | + SSLContext sslContext = null; |
| 834 | + |
| 835 | + try { |
| 836 | + sslContext = new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy() { |
| 837 | + public boolean isTrusted(X509Certificate[] arg0, String arg1) throws CertificateException { |
| 838 | + return true; |
| 839 | + } |
| 840 | + }).build(); |
| 841 | + } catch (Exception e) { |
| 842 | + } |
| 843 | + httpClientBuilder.setSSLContext(sslContext); |
| 844 | + httpClientBuilder.setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE); |
| 845 | + |
826 | 846 | if (authenticator != null) {
|
827 | 847 | authenticator.configureBuilder(httpClientBuilder);
|
828 | 848 |
|
|
0 commit comments