HTTPCLIENT-1182: constructor to org.apache.http.conn.ssl.SSLSocketFactory to allow for directly wrapping a javax.net.ssl.SSLSocketFactory socketfactory

Contributed by Mark Claassen <mclaassen at ocie.net>

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1311941 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2012-04-10 19:22:40 +00:00
parent db9f011a83
commit a9c95e057f

View File

@ -242,7 +242,7 @@ private static SSLContext createSSLContext(
sslcontext.init(keymanagers, trustmanagers, random);
return sslcontext;
}
private static SSLContext createSystemSSLContext(
String algorithm,
final SecureRandom random) throws IOException, NoSuchAlgorithmException, NoSuchProviderException,
@ -481,11 +481,28 @@ public SSLSocketFactory(
public SSLSocketFactory(
final SSLContext sslContext, final X509HostnameVerifier hostnameVerifier) {
super();
if (sslContext == null) {
throw new IllegalArgumentException("SSL context may not be null");
}
this.socketfactory = sslContext.getSocketFactory();
this.hostnameVerifier = hostnameVerifier;
this.nameResolver = null;
}
/**
* @since 4.2
*/
public SSLSocketFactory(
final javax.net.ssl.SSLSocketFactory socketfactory,
final X509HostnameVerifier hostnameVerifier) {
if (socketfactory == null) {
throw new IllegalArgumentException("SSL socket factory may not be null");
}
this.socketfactory = socketfactory;
this.hostnameVerifier = hostnameVerifier;
this.nameResolver = null;
}
/**
* @param params Optional parameters. Parameters passed to this method will have no effect.
* This method will create a unconnected instance of {@link Socket} class.