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