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
This commit is contained in:
Oleg Kalnichevski 2013-03-25 09:15:28 +00:00
parent 96c021c8dd
commit 371b754e1c
1 changed files with 10 additions and 3 deletions

View File

@ -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(