From 371b754e1c9dd911c2b15f9111cffecd54c22cbc Mon Sep 17 00:00:00 2001 From: Oleg Kalnichevski Date: Mon, 25 Mar 2013 09:15:28 +0000 Subject: [PATCH] Added SSLContext as an option for SSL customization git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1460555 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/http/impl/client/HttpClientBuilder.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java b/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java index 3a325f6e2..21357ef96 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java @@ -34,6 +34,8 @@ import java.util.Collection; import java.util.LinkedList; import java.util.List; +import javax.net.ssl.SSLContext; + import org.apache.http.ConnectionReuseStrategy; import org.apache.http.Header; import org.apache.http.HttpHost; @@ -141,6 +143,7 @@ public class HttpClientBuilder { private HttpRequestExecutor requestExec; private LayeredConnectionSocketFactory sslSocketFactory; + private SSLContext sslcontext; private HttpClientConnectionManager connManager; private SchemePortResolver schemePortResolver; private ConnectionReuseStrategy reuseStrategy; @@ -443,10 +446,14 @@ public class HttpClientBuilder { if (connManager == null) { LayeredConnectionSocketFactory sslSocketFactory = this.sslSocketFactory; if (sslSocketFactory == null) { - if (systemProperties) { - sslSocketFactory = SSLSocketFactory.getSystemSocketFactory(); + if (sslcontext != null) { + sslSocketFactory = new SSLSocketFactory(sslcontext); } else { - sslSocketFactory = SSLSocketFactory.getSocketFactory(); + if (systemProperties) { + sslSocketFactory = SSLSocketFactory.getSystemSocketFactory(); + } else { + sslSocketFactory = SSLSocketFactory.getSocketFactory(); + } } } final PoolingHttpClientConnectionManager poolingmgr = new PoolingHttpClientConnectionManager(