Skip to content

Commit 2b735d5

Browse files
author
jgrim
committed
override truststore plugin
1 parent 2726b90 commit 2b735d5

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.11</version>
36+
<version>2.2.11-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
@@ -63,6 +63,8 @@
6363
import java.net.URI;
6464
import java.net.URL;
6565
import java.nio.charset.StandardCharsets;
66+
import java.security.cert.CertificateException;
67+
import java.security.cert.X509Certificate;
6668
import java.util.ArrayList;
6769
import java.util.Collections;
6870
import java.util.Comparator;
@@ -93,6 +95,7 @@
9395
import org.apache.http.client.methods.HttpPut;
9496
import org.apache.http.client.methods.HttpRequestBase;
9597
import org.apache.http.client.protocol.HttpClientContext;
98+
import org.apache.http.conn.ssl.NoopHostnameVerifier;
9699
import org.apache.http.entity.ContentType;
97100
import org.apache.http.entity.StringEntity;
98101
import org.apache.http.impl.auth.BasicScheme;
@@ -101,9 +104,13 @@
101104
import org.apache.http.impl.client.CloseableHttpClient;
102105
import org.apache.http.impl.client.HttpClientBuilder;
103106
import org.apache.http.message.BasicNameValuePair;
107+
import org.apache.http.ssl.SSLContextBuilder;
108+
import org.apache.http.ssl.TrustStrategy;
104109
import org.apache.http.util.EntityUtils;
105110
import org.codehaus.jackson.type.TypeReference;
106111

112+
import javax.net.ssl.SSLContext;
113+
107114
/**
108115
* Bitbucket API client.
109116
* Developed and test with Bitbucket 4.3.2
@@ -666,6 +673,19 @@ private String getRequest(String path) throws IOException {
666673
private CloseableHttpClient getHttpClient(String host) {
667674
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
668675

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

0 commit comments

Comments
 (0)