Skip to content

Commit 753f809

Browse files
author
jgrim
committed
override truststore plugin
1 parent 869ac9e commit 753f809

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
</parent>
3434

3535
<artifactId>cloudbees-bitbucket-branch-source</artifactId>
36-
<version>2.2.10</version>
36+
<version>2.2.10-patch</version>
3737
<packaging>hpi</packaging>
3838

3939
<name>Bitbucket Branch Source Plugin</name>

src/main/java/com/cloudbees/jenkins/plugins/bitbucket/server/client/BitbucketServerAPIClient.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@
6262
import java.net.URI;
6363
import java.net.URL;
6464
import java.nio.charset.StandardCharsets;
65+
import java.security.cert.CertificateException;
66+
import java.security.cert.X509Certificate;
6567
import java.util.ArrayList;
6668
import java.util.Collections;
6769
import java.util.Comparator;
@@ -92,6 +94,7 @@
9294
import org.apache.http.client.methods.HttpPut;
9395
import org.apache.http.client.methods.HttpRequestBase;
9496
import org.apache.http.client.protocol.HttpClientContext;
97+
import org.apache.http.conn.ssl.NoopHostnameVerifier;
9598
import org.apache.http.entity.ContentType;
9699
import org.apache.http.entity.StringEntity;
97100
import org.apache.http.impl.auth.BasicScheme;
@@ -100,9 +103,13 @@
100103
import org.apache.http.impl.client.CloseableHttpClient;
101104
import org.apache.http.impl.client.HttpClientBuilder;
102105
import org.apache.http.message.BasicNameValuePair;
106+
import org.apache.http.ssl.SSLContextBuilder;
107+
import org.apache.http.ssl.TrustStrategy;
103108
import org.apache.http.util.EntityUtils;
104109
import org.codehaus.jackson.type.TypeReference;
105110

111+
import javax.net.ssl.SSLContext;
112+
106113
/**
107114
* Bitbucket API client.
108115
* Developed and test with Bitbucket 4.3.2
@@ -650,6 +657,19 @@ private String getRequest(String path) throws IOException {
650657
private CloseableHttpClient getHttpClient(String host) {
651658
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
652659

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+
653673
if (credentials != null) {
654674
CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
655675
credentialsProvider.setCredentials(AuthScope.ANY, credentials);

0 commit comments

Comments
 (0)