Top Description Fields Constructors Methods
org.apache.http.conn.ssl

public Class SSLSocketFactory

extends Object
implements LayeredConnectionSocketFactory, SchemeLayeredSocketFactory, LayeredSchemeSocketFactory, LayeredSocketFactory
Class Inheritance
All Implemented Interfaces
org.apache.http.conn.scheme.LayeredSocketFactory, org.apache.http.conn.scheme.SocketFactory, org.apache.http.conn.scheme.LayeredSchemeSocketFactory, org.apache.http.conn.scheme.SchemeSocketFactory, org.apache.http.conn.scheme.SchemeLayeredSocketFactory, org.apache.http.conn.socket.LayeredConnectionSocketFactory, org.apache.http.conn.socket.ConnectionSocketFactory
Annotations
@Contract
threading:SAFE_CONDITIONAL
@Deprecated
Imports
java.io.IOException, java.net.InetAddress, .InetSocketAddress, .Socket, .SocketTimeoutException, .UnknownHostException, java.security.KeyManagementException, .KeyStore, .KeyStoreException, .NoSuchAlgorithmException, .SecureRandom, .UnrecoverableKeyException, javax.net.SocketFactory, javax.net.ssl.SSLContext, .SSLSocket, org.apache.http.HttpHost, org.apache.http.annotation.Contract, .ThreadingBehavior, org.apache.http.conn.ConnectTimeoutException, .HttpInetSocketAddress, org.apache.http.conn.scheme.HostNameResolver, .LayeredSchemeSocketFactory, .LayeredSocketFactory, .SchemeLayeredSocketFactory, org.apache.http.conn.socket.LayeredConnectionSocketFactory, org.apache.http.params.HttpConnectionParams, .HttpParams, org.apache.http.protocol.HttpContext, org.apache.http.util.Args, .Asserts, .TextUtils

Deprecated

(4.3) use SSLConnectionSocketFactory.

Layered socket factory for TLS/SSL connections.

SSLSocketFactory can be used to validate the identity of the HTTPS server against a list of trusted certificates and to authenticate to the HTTPS server using a private key.

SSLSocketFactory will enable server authentication when supplied with a trust-store file containing one or several trusted certificates. The client secure socket will reject the connection during the SSL session handshake if the target HTTPS server attempts to authenticate itself with a non-trusted certificate.

Use JDK keytool utility to import a trusted certificate and generate a trust-store file:

keytool -import -alias "my server cert" -file server.crt -keystore my.truststore

In special cases the standard trust verification process can be bypassed by using a custom TrustStrategy. This interface is primarily intended for allowing self-signed certificates to be accepted as trusted without having to add them to the trust-store file.

SSLSocketFactory will enable client authentication when supplied with a key-store file containing a private key/public certificate pair. The client secure socket will use the private key to authenticate itself to the target HTTPS server during the SSL session handshake if requested to do so by the server. The target HTTPS server will in its turn verify the certificate presented by the client in order to establish client's authenticity.

Use the following sequence of actions to generate a key-store file

Since
4.0

Field Summary

Modifier and TypeField and Description
public static final X509HostnameVerifier
ALLOW_ALL_HOSTNAME_VERIFIER

Deprecated as a consequence of X509HostnameVerifier being deprecated.
public static final X509HostnameVerifier
BROWSER_COMPATIBLE_HOSTNAME_VERIFIER

Deprecated as a consequence of X509HostnameVerifier being deprecated.
private volatile X509HostnameVerifier
hostnameVerifier

Deprecated as a consequence of X509HostnameVerifier being deprecated.
private final HostNameResolver
nameResolver

Deprecated as a consequence of HostNameResolver being deprecated.
private final SSLSocketFactory
public static final String
public static final String
public static final X509HostnameVerifier
STRICT_HOSTNAME_VERIFIER

Deprecated as a consequence of X509HostnameVerifier being deprecated.
private final String[]
private final String[]
public static final String

Constructor Summary

AccessConstructor and Description
public
SSLSocketFactory(final String algorithm, final KeyStore keystore, final String keyPassword, final KeyStore truststore, final SecureRandom random, final HostNameResolver nameResolver)

Deprecated as a consequence of HostNameResolver being deprecated.
public
SSLSocketFactory(final String algorithm, final KeyStore keystore, final String keyPassword, final KeyStore truststore, final SecureRandom random, final TrustStrategy trustStrategy, final X509HostnameVerifier hostnameVerifier)

Deprecated as a consequence of X509HostnameVerifier being deprecated.
public
SSLSocketFactory(final String algorithm, final KeyStore keystore, final String keyPassword, final KeyStore truststore, final SecureRandom random, final X509HostnameVerifier hostnameVerifier)

Deprecated as a consequence of X509HostnameVerifier being deprecated.
public
SSLSocketFactory(final KeyStore keystore, final String keystorePassword, final KeyStore truststore)

public
SSLSocketFactory(final KeyStore keystore, final String keystorePassword)

public
SSLSocketFactory(final KeyStore truststore)

public
SSLSocketFactory(final TrustStrategy trustStrategy, final X509HostnameVerifier hostnameVerifier)

Deprecated as a consequence of X509HostnameVerifier being deprecated.
public
SSLSocketFactory(final TrustStrategy trustStrategy)

public
SSLSocketFactory(final SSLContext sslContext)

public
SSLSocketFactory(final SSLContext sslContext, final HostNameResolver nameResolver)

Deprecated as a consequence of HostNameResolver being deprecated.
public
SSLSocketFactory(final SSLContext sslContext, final X509HostnameVerifier hostnameVerifier)

Deprecated as a consequence of X509HostnameVerifier being deprecated.
public
SSLSocketFactory(final SSLContext sslContext, final String[] supportedProtocols, final String[] supportedCipherSuites, final X509HostnameVerifier hostnameVerifier)

Deprecated as a consequence of X509HostnameVerifier being deprecated.
public
SSLSocketFactory(final SSLSocketFactory socketfactory, final X509HostnameVerifier hostnameVerifier)

Deprecated as a consequence of X509HostnameVerifier being deprecated.
public
SSLSocketFactory(final SSLSocketFactory socketfactory, final String[] supportedProtocols, final String[] supportedCipherSuites, final X509HostnameVerifier hostnameVerifier)

Deprecated as a consequence of X509HostnameVerifier being deprecated.

Method Summary

Modifier and TypeMethod and Description
public Socket
connectSocket(final Socket
the socket to connect, as obtained from createSocket. null indicates that a new socket should be created and connected.
socket
,
final InetSocketAddress
the remote address to connect to.
remoteAddress
,
final InetSocketAddress
the local address to bind the socket to, or null for any
localAddress
,
final HttpParams
additional parameters for connecting
params
)

Implements org.apache.http.conn.scheme.SchemeSocketFactory.connectSocket.

Deprecated as a consequence of HttpParams being deprecated.
Connects a socket to the target host with the given remote address.
public Socket
connectSocket(final Socket
the socket to connect, as obtained from createSocket. null indicates that a new socket should be created and connected.
socket
,
final String
the host to connect to
host
,
final int
the port to connect to on the host
port
,
final InetAddress
the local address to bind the socket to, or null for any
local
,
final int
the port on the local machine, 0 or a negative number for any
localPort
,
final HttpParams
additional parameters for connecting
params
)

Implements org.apache.http.conn.scheme.SocketFactory.connectSocket.

Deprecated as a consequence of HttpParams being deprecated.
Connects a socket to the given host.
public Socket
connectSocket(final int
connect timeout.
connectTimeout
,
final Socket
the socket to connect, as obtained from createSocket(HttpContext). null indicates that a new socket should be created and connected.
socket
,
final HttpHost
target host as specified by the caller (end user).
host
,
final InetSocketAddress
the resolved remote address to connect to.
remoteAddress
,
final InetSocketAddress
the local address to bind the socket to, or null for any.
localAddress
,
final HttpContext
the actual HTTP context.
context
)

Implements org.apache.http.conn.socket.ConnectionSocketFactory.connectSocket.

Connects the socket to the target host with the given resolved remote address.
public Socket
createLayeredSocket(final Socket
the existing socket
socket
,
final String
the name of the target host.
host
,
final int
the port to connect to on the target host
port
,
final HttpParams
HTTP parameters
params
)

Implements org.apache.http.conn.scheme.SchemeLayeredSocketFactory.createLayeredSocket.

Deprecated as a consequence of HttpParams being deprecated.
Returns a socket connected to the given host that is layered over an existing socket.
public Socket
createLayeredSocket(final Socket
the existing socket
socket
,
final String
the name of the target host.
host
,
final int
the port to connect to on the target host
port
,
final boolean
a flag for closing the underling socket when the created socket is closed
autoClose
)

Implements org.apache.http.conn.scheme.LayeredSchemeSocketFactory.createLayeredSocket.

Returns a socket connected to the given host that is layered over an existing socket.
public Socket
createLayeredSocket(final Socket
the existing socket
socket
,
final String
the name of the target host.
target
,
final int
the port to connect to on the target host.
port
,
final HttpContext
the actual HTTP context.
context
)

Implements org.apache.http.conn.socket.LayeredConnectionSocketFactory.createLayeredSocket.

Returns a socket connected to the given host that is layered over an existing socket.
public Socket
createSocket(final HttpParams
Optional parameters. Parameters passed to this method will have no effect. This method will create a unconnected instance of Socket class.
params
)

Implements org.apache.http.conn.scheme.SchemeSocketFactory.createSocket.

Deprecated as a consequence of HttpParams being deprecated.
Creates a new, unconnected socket.
public Socket
createSocket()

Implements org.apache.http.conn.scheme.SocketFactory.createSocket.

Creates a new, unconnected socket.
public Socket
createSocket(final Socket
the existing socket
socket
,
final String
the host name/IP
host
,
final int
the port on the host
port
,
final boolean
a flag for closing the underling socket when the created socket is closed
autoClose
)

Implements org.apache.http.conn.scheme.LayeredSocketFactory.createSocket.

Returns a socket connected to the given host that is layered over an existing socket.
public Socket
createSocket(final HttpContext context)

Implements org.apache.http.conn.socket.ConnectionSocketFactory.createSocket.

Creates new, unconnected socket.
public X509HostnameVerifier
getHostnameVerifier()

Deprecated as a consequence of X509HostnameVerifier being deprecated.
public static SSLSocketFactory

Returns:

default SSL socket factory
getSocketFactory
()

Deprecated as a consequence of SSLSocketFactory being deprecated.
Obtains default SSL socket factory with an SSL context based on the standard JSSE trust material (cacerts file in the security properties directory).
public static SSLSocketFactory

Returns:

default system SSL socket factory
getSystemSocketFactory
()

Deprecated as a consequence of SSLSocketFactory being deprecated.
Obtains default SSL socket factory with an SSL context based on system properties as described in "JavaTM Secure Socket Extension (JSSE) Reference Guide for the JavaTM 2 Platform Standard Edition 5
private void
public boolean

Returns:

true
isSecure
(final Socket
the connected socket
sock
)

Implements org.apache.http.conn.scheme.SchemeSocketFactory.isSecure, org.apache.http.conn.scheme.SocketFactory.isSecure.

Checks whether a socket connection is secure.
protected void
prepareSocket(final SSLSocket socket)

Performs any custom initialization for a newly created SSLSocket (before the SSL handshake happens).

public void
setHostnameVerifier(final X509HostnameVerifier hostnameVerifier)

Deprecated as a consequence of X509HostnameVerifier being deprecated.
private static String[]
split(final String s)

private void
verifyHostname(final SSLSocket sslsock, final String hostname)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ALLOW_ALL_HOSTNAME_VERIFIERback to summary
public static final X509HostnameVerifier ALLOW_ALL_HOSTNAME_VERIFIER

Deprecated

as a consequence of X509HostnameVerifier being deprecated. See corresponding docs for further information.

BROWSER_COMPATIBLE_HOSTNAME_VERIFIERback to summary
public static final X509HostnameVerifier BROWSER_COMPATIBLE_HOSTNAME_VERIFIER

Deprecated

as a consequence of X509HostnameVerifier being deprecated. See corresponding docs for further information.

hostnameVerifierback to summary
private volatile X509HostnameVerifier hostnameVerifier

Deprecated

as a consequence of X509HostnameVerifier being deprecated. See corresponding docs for further information.

nameResolverback to summary
private final HostNameResolver nameResolver

Deprecated

as a consequence of HostNameResolver being deprecated. See corresponding docs for further information.

socketfactoryback to summary
private final SSLSocketFactory socketfactory
SSLback to summary
public static final String SSL
SSLV2back to summary
public static final String SSLV2
STRICT_HOSTNAME_VERIFIERback to summary
public static final X509HostnameVerifier STRICT_HOSTNAME_VERIFIER

Deprecated

as a consequence of X509HostnameVerifier being deprecated. See corresponding docs for further information.

supportedCipherSuitesback to summary
private final String[] supportedCipherSuites
supportedProtocolsback to summary
private final String[] supportedProtocols
TLSback to summary
public static final String TLS

Constructor Detail

SSLSocketFactoryback to summary
public SSLSocketFactory(final String algorithm, final KeyStore keystore, final String keyPassword, final KeyStore truststore, final SecureRandom random, final HostNameResolver nameResolver) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException

Deprecated

as a consequence of HostNameResolver being deprecated. See corresponding docs for further information.

SSLSocketFactoryback to summary
public SSLSocketFactory(final String algorithm, final KeyStore keystore, final String keyPassword, final KeyStore truststore, final SecureRandom random, final TrustStrategy trustStrategy, final X509HostnameVerifier hostnameVerifier) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException

Deprecated

as a consequence of X509HostnameVerifier being deprecated. See corresponding docs for further information.

Since
4.1
SSLSocketFactoryback to summary
public SSLSocketFactory(final String algorithm, final KeyStore keystore, final String keyPassword, final KeyStore truststore, final SecureRandom random, final X509HostnameVerifier hostnameVerifier) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException

Deprecated

as a consequence of X509HostnameVerifier being deprecated. See corresponding docs for further information.

Since
4.1
SSLSocketFactoryback to summary
public SSLSocketFactory(final KeyStore keystore, final String keystorePassword, final KeyStore truststore) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException
SSLSocketFactoryback to summary
public SSLSocketFactory(final KeyStore keystore, final String keystorePassword) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException
SSLSocketFactoryback to summary
public SSLSocketFactory(final KeyStore truststore) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException
SSLSocketFactoryback to summary
public SSLSocketFactory(final TrustStrategy trustStrategy, final X509HostnameVerifier hostnameVerifier) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException

Deprecated

as a consequence of X509HostnameVerifier being deprecated. See corresponding docs for further information.

Since
4.1
SSLSocketFactoryback to summary
public SSLSocketFactory(final TrustStrategy trustStrategy) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException
Since
4.1
SSLSocketFactoryback to summary
public SSLSocketFactory(final SSLContext sslContext)
SSLSocketFactoryback to summary
public SSLSocketFactory(final SSLContext sslContext, final HostNameResolver nameResolver)

Deprecated

as a consequence of HostNameResolver being deprecated. See corresponding docs for further information.

SSLSocketFactoryback to summary
public SSLSocketFactory(final SSLContext sslContext, final X509HostnameVerifier hostnameVerifier)

Deprecated

as a consequence of X509HostnameVerifier being deprecated. See corresponding docs for further information.

Since
4.1
SSLSocketFactoryback to summary
public SSLSocketFactory(final SSLContext sslContext, final String[] supportedProtocols, final String[] supportedCipherSuites, final X509HostnameVerifier hostnameVerifier)

Deprecated

as a consequence of X509HostnameVerifier being deprecated. See corresponding docs for further information.

Since
4.3
SSLSocketFactoryback to summary
public SSLSocketFactory(final SSLSocketFactory socketfactory, final X509HostnameVerifier hostnameVerifier)

Deprecated

as a consequence of X509HostnameVerifier being deprecated. See corresponding docs for further information.

Since
4.2
SSLSocketFactoryback to summary
public SSLSocketFactory(final SSLSocketFactory socketfactory, final String[] supportedProtocols, final String[] supportedCipherSuites, final X509HostnameVerifier hostnameVerifier)

Deprecated

as a consequence of X509HostnameVerifier being deprecated. See corresponding docs for further information.

Since
4.3

Method Detail

connectSocketback to summary
public Socket connectSocket(final Socket socket, final InetSocketAddress remoteAddress, final InetSocketAddress localAddress, final HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException

Implements org.apache.http.conn.scheme.SchemeSocketFactory.connectSocket.

Doc from org.apache.http.conn.scheme.SchemeSocketFactory.connectSocket.

Deprecated

as a consequence of HttpParams being deprecated. See corresponding docs for further information.

Connects a socket to the target host with the given remote address.

Please note that org.apache.http.conn.HttpInetSocketAddress class should be used in order to pass the target remote address along with the original org.apache.http.HttpHost value used to resolve the address. The use of org.apache.http.conn.HttpInetSocketAddress can also ensure that no reverse DNS lookup will be performed if the target remote address was specified as an IP address.

Parameters
socket:Socket

the socket to connect, as obtained from createSocket. null indicates that a new socket should be created and connected.

remoteAddress:InetSocketAddress

the remote address to connect to.

localAddress:InetSocketAddress

the local address to bind the socket to, or null for any

params:HttpParams

additional parameters for connecting

Returns:Socket

the connected socket. The returned object may be different from the sock argument if this factory supports a layered protocol.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
UnknownHostException:
if the IP address of the target host can not be determined
ConnectTimeoutException:
if the socket cannot be connected within the time limit defined in the params
Since
4.1
connectSocketback to summary
public Socket connectSocket(final Socket socket, final String host, final int port, final InetAddress local, final int localPort, final HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException

Implements org.apache.http.conn.scheme.SocketFactory.connectSocket.

Doc from org.apache.http.conn.scheme.SocketFactory.connectSocket.

Deprecated

as a consequence of HttpParams being deprecated. See corresponding docs for further information.

Connects a socket to the given host.

Parameters
socket:Socket

the socket to connect, as obtained from createSocket. null indicates that a new socket should be created and connected.

host:String

the host to connect to

port:int

the port to connect to on the host

local:InetAddress

the local address to bind the socket to, or null for any

localPort:int

the port on the local machine, 0 or a negative number for any

params:HttpParams

additional parameters for connecting

Returns:Socket

the connected socket. The returned object may be different from the sock argument if this factory supports a layered protocol.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
UnknownHostException:
if the IP address of the target host can not be determined
ConnectTimeoutException:
if the socket cannot be connected within the time limit defined in the params
connectSocketback to summary
public Socket connectSocket(final int connectTimeout, final Socket socket, final HttpHost host, final InetSocketAddress remoteAddress, final InetSocketAddress localAddress, final HttpContext context) throws IOException

Implements org.apache.http.conn.socket.ConnectionSocketFactory.connectSocket.

Doc from org.apache.http.conn.socket.ConnectionSocketFactory.connectSocket.

Connects the socket to the target host with the given resolved remote address.

Parameters
connectTimeout:int

connect timeout.

socket:Socket

the socket to connect, as obtained from createSocket(HttpContext). null indicates that a new socket should be created and connected.

host:HttpHost

target host as specified by the caller (end user).

remoteAddress:InetSocketAddress

the resolved remote address to connect to.

localAddress:InetSocketAddress

the local address to bind the socket to, or null for any.

context:HttpContext

the actual HTTP context.

Returns:Socket

the connected socket. The returned object may be different from the sock argument if this factory supports a layered protocol.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
createLayeredSocketback to summary
public Socket createLayeredSocket(final Socket socket, final String host, final int port, final HttpParams params) throws IOException, UnknownHostException

Implements org.apache.http.conn.scheme.SchemeLayeredSocketFactory.createLayeredSocket.

Doc from org.apache.http.conn.scheme.SchemeLayeredSocketFactory.createLayeredSocket.

Deprecated

as a consequence of HttpParams being deprecated. See corresponding docs for further information.

Returns a socket connected to the given host that is layered over an existing socket. Used primarily for creating secure sockets through proxies.

Parameters
socket:Socket

the existing socket

host:String

the name of the target host.

port:int

the port to connect to on the target host

params:HttpParams

HTTP parameters

Returns:Socket

Socket a new socket

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs while creating the socket
UnknownHostException:
if the IP address of the host cannot be determined
Since
4.2
createLayeredSocketback to summary
public Socket createLayeredSocket(final Socket socket, final String host, final int port, final boolean autoClose) throws IOException, UnknownHostException

Implements org.apache.http.conn.scheme.LayeredSchemeSocketFactory.createLayeredSocket.

Doc from org.apache.http.conn.scheme.LayeredSchemeSocketFactory.createLayeredSocket.

Returns a socket connected to the given host that is layered over an existing socket. Used primarily for creating secure sockets through proxies.

Parameters
socket:Socket

the existing socket

host:String

the name of the target host.

port:int

the port to connect to on the target host

autoClose:boolean

a flag for closing the underling socket when the created socket is closed

Returns:Socket

Socket a new socket

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs while creating the socket
UnknownHostException:
if the IP address of the host cannot be determined
createLayeredSocketback to summary
public Socket createLayeredSocket(final Socket socket, final String target, final int port, final HttpContext context) throws IOException

Implements org.apache.http.conn.socket.LayeredConnectionSocketFactory.createLayeredSocket.

Doc from org.apache.http.conn.socket.LayeredConnectionSocketFactory.createLayeredSocket.

Returns a socket connected to the given host that is layered over an existing socket. Used primarily for creating secure sockets through proxies.

Parameters
socket:Socket

the existing socket

target:String

the name of the target host.

port:int

the port to connect to on the target host.

context:HttpContext

the actual HTTP context.

Returns:Socket

Socket a new socket

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs while creating the socket
createSocketback to summary
public Socket createSocket(final HttpParams params) throws IOException

Implements org.apache.http.conn.scheme.SchemeSocketFactory.createSocket.

Doc from org.apache.http.conn.scheme.SchemeSocketFactory.createSocket.

Deprecated

as a consequence of HttpParams being deprecated. See corresponding docs for further information.

Creates a new, unconnected socket. The socket should subsequently be passed to connectSocket(Socket, InetSocketAddress, InetSocketAddress, HttpParams).

Parameters
params:HttpParams

Optional parameters. Parameters passed to this method will have no effect. This method will create a unconnected instance of Socket class.

Returns:Socket

a new socket

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs while creating the socket
Since
4.1
createSocketback to summary
public Socket createSocket() throws IOException

Implements org.apache.http.conn.scheme.SocketFactory.createSocket.

Doc from org.apache.http.conn.scheme.SocketFactory.createSocket.

Creates a new, unconnected socket. The socket should subsequently be passed to connectSocket.

Returns:Socket

a new socket

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs while creating the socket
createSocketback to summary
public Socket createSocket(final Socket socket, final String host, final int port, final boolean autoClose) throws IOException, UnknownHostException

Implements org.apache.http.conn.scheme.LayeredSocketFactory.createSocket.

Doc from org.apache.http.conn.scheme.LayeredSocketFactory.createSocket.

Returns a socket connected to the given host that is layered over an existing socket. Used primarily for creating secure sockets through proxies.

Parameters
socket:Socket

the existing socket

host:String

the host name/IP

port:int

the port on the host

autoClose:boolean

a flag for closing the underling socket when the created socket is closed

Returns:Socket

Socket a new socket

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs while creating the socket
UnknownHostException:
if the IP address of the host cannot be determined
createSocketback to summary
public Socket createSocket(final HttpContext context) throws IOException

Implements org.apache.http.conn.socket.ConnectionSocketFactory.createSocket.

Doc from org.apache.http.conn.socket.ConnectionSocketFactory.createSocket.

Creates new, unconnected socket. The socket should subsequently be passed to connectSocket method.

Returns:Socket

a new socket

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs while creating the socket
getHostnameVerifierback to summary
public X509HostnameVerifier getHostnameVerifier()

Deprecated

as a consequence of X509HostnameVerifier being deprecated. See corresponding docs for further information.

getSocketFactoryback to summary
public static SSLSocketFactory getSocketFactory() throws SSLInitializationException

Deprecated

as a consequence of SSLSocketFactory being deprecated. See corresponding docs for further information.

Obtains default SSL socket factory with an SSL context based on the standard JSSE trust material (cacerts file in the security properties directory). System properties are not taken into consideration.

Returns:SSLSocketFactory

default SSL socket factory

getSystemSocketFactoryback to summary
public static SSLSocketFactory getSystemSocketFactory() throws SSLInitializationException

Deprecated

as a consequence of SSLSocketFactory being deprecated. See corresponding docs for further information.

Obtains default SSL socket factory with an SSL context based on system properties as described in "JavaTM Secure Socket Extension (JSSE) Reference Guide for the JavaTM 2 Platform Standard Edition 5

Returns:SSLSocketFactory

default system SSL socket factory

internalPrepareSocketback to summary
private void internalPrepareSocket(final SSLSocket socket) throws IOException
isSecureback to summary
public boolean isSecure(final Socket sock) throws IllegalArgumentException

Implements org.apache.http.conn.scheme.SchemeSocketFactory.isSecure, org.apache.http.conn.scheme.SocketFactory.isSecure.

Checks whether a socket connection is secure. This factory creates TLS/SSL socket connections which, by default, are considered secure.

Derived classes may override this method to perform runtime checks, for example based on the cypher suite.

Parameters
sock:Socket

the connected socket

Returns:boolean

true

Annotations
@Override
Exceptions
IllegalArgumentException:
if the argument is invalid
prepareSocketback to summary
protected void prepareSocket(final SSLSocket socket) throws IOException

Performs any custom initialization for a newly created SSLSocket (before the SSL handshake happens). The default implementation is a no-op, but could be overridden to, e.g., call SSLSocket#setEnabledCipherSuites(java.lang.String[]).

Exceptions
IOException:
(only if overridden)
Since
4.2
setHostnameVerifierback to summary
public void setHostnameVerifier(final X509HostnameVerifier hostnameVerifier)

Deprecated

as a consequence of X509HostnameVerifier being deprecated. See corresponding docs for further information.

splitback to summary
private static String[] split(final String s)
verifyHostnameback to summary
private void verifyHostname(final SSLSocket sslsock, final String hostname) throws IOException