|
62 | 62 | import java.net.URI;
|
63 | 63 | import java.net.URL;
|
64 | 64 | import java.nio.charset.StandardCharsets;
|
| 65 | +import java.security.cert.CertificateException; |
| 66 | +import java.security.cert.X509Certificate; |
65 | 67 | import java.util.ArrayList;
|
66 | 68 | import java.util.Collections;
|
67 | 69 | import java.util.Comparator;
|
|
92 | 94 | import org.apache.http.client.methods.HttpPut;
|
93 | 95 | import org.apache.http.client.methods.HttpRequestBase;
|
94 | 96 | import org.apache.http.client.protocol.HttpClientContext;
|
| 97 | +import org.apache.http.conn.ssl.NoopHostnameVerifier; |
95 | 98 | import org.apache.http.entity.ContentType;
|
96 | 99 | import org.apache.http.entity.StringEntity;
|
97 | 100 | import org.apache.http.impl.auth.BasicScheme;
|
|
100 | 103 | import org.apache.http.impl.client.CloseableHttpClient;
|
101 | 104 | import org.apache.http.impl.client.HttpClientBuilder;
|
102 | 105 | import org.apache.http.message.BasicNameValuePair;
|
| 106 | +import org.apache.http.ssl.SSLContextBuilder; |
| 107 | +import org.apache.http.ssl.TrustStrategy; |
103 | 108 | import org.apache.http.util.EntityUtils;
|
104 | 109 | import org.codehaus.jackson.type.TypeReference;
|
105 | 110 |
|
| 111 | +import javax.net.ssl.SSLContext; |
| 112 | + |
106 | 113 | /**
|
107 | 114 | * Bitbucket API client.
|
108 | 115 | * Developed and test with Bitbucket 4.3.2
|
@@ -650,6 +657,19 @@ private String getRequest(String path) throws IOException {
|
650 | 657 | private CloseableHttpClient getHttpClient(String host) {
|
651 | 658 | HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
|
652 | 659 |
|
| 660 | + SSLContext sslContext = null; |
| 661 | + |
| 662 | + try { |
| 663 | + sslContext = new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy() { |
| 664 | + public boolean isTrusted(X509Certificate[] arg0, String arg1) throws CertificateException { |
| 665 | + return true; |
| 666 | + } |
| 667 | + }).build(); |
| 668 | + } catch (Exception e) { |
| 669 | + } |
| 670 | + httpClientBuilder.setSSLContext(sslContext); |
| 671 | + httpClientBuilder.setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE); |
| 672 | + |
653 | 673 | if (credentials != null) {
|
654 | 674 | CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
|
655 | 675 | credentialsProvider.setCredentials(AuthScope.ANY, credentials);
|
|
0 commit comments