|
73 | 73 | import java.net.URI;
|
74 | 74 | import java.net.URISyntaxException;
|
75 | 75 | import java.nio.charset.StandardCharsets;
|
| 76 | +import java.security.cert.CertificateException; |
| 77 | +import java.security.cert.X509Certificate; |
76 | 78 | import java.util.ArrayList;
|
77 | 79 | import java.util.Collections;
|
78 | 80 | import java.util.Comparator;
|
|
83 | 85 | import java.util.logging.Level;
|
84 | 86 | import java.util.logging.Logger;
|
85 | 87 | import javax.imageio.ImageIO;
|
| 88 | +import javax.net.ssl.SSLContext; |
86 | 89 | import jenkins.model.Jenkins;
|
87 | 90 | import jenkins.scm.api.SCMFile;
|
88 | 91 | import net.sf.json.JSONObject;
|
|
105 | 108 | import org.apache.http.client.methods.HttpPut;
|
106 | 109 | import org.apache.http.client.methods.HttpRequestBase;
|
107 | 110 | import org.apache.http.client.protocol.HttpClientContext;
|
| 111 | +import org.apache.http.conn.ssl.NoopHostnameVerifier; |
108 | 112 | import org.apache.http.entity.ContentType;
|
109 | 113 | import org.apache.http.entity.StringEntity;
|
110 | 114 | import org.apache.http.impl.auth.BasicScheme;
|
|
113 | 117 | import org.apache.http.impl.client.CloseableHttpClient;
|
114 | 118 | import org.apache.http.impl.client.HttpClientBuilder;
|
115 | 119 | import org.apache.http.message.BasicNameValuePair;
|
| 120 | +import org.apache.http.ssl.SSLContextBuilder; |
| 121 | +import org.apache.http.ssl.TrustStrategy; |
116 | 122 | import org.apache.http.util.EntityUtils;
|
117 | 123 |
|
118 | 124 | import static java.util.Objects.requireNonNull;
|
@@ -894,6 +900,20 @@ private BufferedImage getImageRequest(String path) throws IOException, Interrupt
|
894 | 900 | */
|
895 | 901 | private CloseableHttpClient getHttpClient(final HttpRequestBase request) {
|
896 | 902 | HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
|
| 903 | + |
| 904 | + SSLContext sslContext = null; |
| 905 | + |
| 906 | + try { |
| 907 | + sslContext = new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy() { |
| 908 | + public boolean isTrusted(X509Certificate[] arg0, String arg1) throws CertificateException { |
| 909 | + return true; |
| 910 | + } |
| 911 | + }).build(); |
| 912 | + } catch (Exception e) { |
| 913 | + } |
| 914 | + httpClientBuilder.setSSLContext(sslContext); |
| 915 | + httpClientBuilder.setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE); |
| 916 | + |
897 | 917 | httpClientBuilder.useSystemProperties();
|
898 | 918 |
|
899 | 919 | RequestConfig.Builder requestConfig = RequestConfig.custom();
|
|
0 commit comments