Pass HttpContext to SSLConnectionSocketFactory#prepareSocket method (#404)
This commit is contained in:
parent
3403571c18
commit
4695041df4
|
@ -178,6 +178,13 @@ public class SSLConnectionSocketFactory implements LayeredConnectionSocketFactor
|
||||||
this.tlsSessionValidator = new TlsSessionValidator(LOG);
|
this.tlsSessionValidator = new TlsSessionValidator(LOG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use {@link #prepareSocket(SSLSocket, HttpContext)}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
protected void prepareSocket(final SSLSocket socket) throws IOException {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs any custom initialization for a newly created SSLSocket
|
* Performs any custom initialization for a newly created SSLSocket
|
||||||
* (before the SSL handshake happens).
|
* (before the SSL handshake happens).
|
||||||
|
@ -186,7 +193,9 @@ public class SSLConnectionSocketFactory implements LayeredConnectionSocketFactor
|
||||||
* call {@link javax.net.ssl.SSLSocket#setEnabledCipherSuites(String[])}.
|
* call {@link javax.net.ssl.SSLSocket#setEnabledCipherSuites(String[])}.
|
||||||
* @throws IOException may be thrown if overridden
|
* @throws IOException may be thrown if overridden
|
||||||
*/
|
*/
|
||||||
protected void prepareSocket(final SSLSocket socket) throws IOException {
|
@SuppressWarnings("deprecation")
|
||||||
|
protected void prepareSocket(final SSLSocket socket, final HttpContext context) throws IOException {
|
||||||
|
prepareSocket(socket);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -245,7 +254,7 @@ public class SSLConnectionSocketFactory implements LayeredConnectionSocketFactor
|
||||||
// Setup SSL layering if necessary
|
// Setup SSL layering if necessary
|
||||||
if (sock instanceof SSLSocket) {
|
if (sock instanceof SSLSocket) {
|
||||||
final SSLSocket sslsock = (SSLSocket) sock;
|
final SSLSocket sslsock = (SSLSocket) sock;
|
||||||
executeHandshake(sslsock, host.getHostName(), attachment);
|
executeHandshake(sslsock, host.getHostName(), attachment, context);
|
||||||
return sock;
|
return sock;
|
||||||
}
|
}
|
||||||
return createLayeredSocket(sock, host.getHostName(), remoteAddress.getPort(), attachment, context);
|
return createLayeredSocket(sock, host.getHostName(), remoteAddress.getPort(), attachment, context);
|
||||||
|
@ -272,11 +281,15 @@ public class SSLConnectionSocketFactory implements LayeredConnectionSocketFactor
|
||||||
target,
|
target,
|
||||||
port,
|
port,
|
||||||
true);
|
true);
|
||||||
executeHandshake(sslsock, target, attachment);
|
executeHandshake(sslsock, target, attachment, context);
|
||||||
return sslsock;
|
return sslsock;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void executeHandshake(final SSLSocket sslsock, final String target, final Object attachment) throws IOException {
|
private void executeHandshake(
|
||||||
|
final SSLSocket sslsock,
|
||||||
|
final String target,
|
||||||
|
final Object attachment,
|
||||||
|
final HttpContext context) throws IOException {
|
||||||
final TlsConfig tlsConfig = attachment instanceof TlsConfig ? (TlsConfig) attachment : TlsConfig.DEFAULT;
|
final TlsConfig tlsConfig = attachment instanceof TlsConfig ? (TlsConfig) attachment : TlsConfig.DEFAULT;
|
||||||
if (supportedProtocols != null) {
|
if (supportedProtocols != null) {
|
||||||
sslsock.setEnabledProtocols(supportedProtocols);
|
sslsock.setEnabledProtocols(supportedProtocols);
|
||||||
|
@ -293,7 +306,7 @@ public class SSLConnectionSocketFactory implements LayeredConnectionSocketFactor
|
||||||
sslsock.setSoTimeout(handshakeTimeout.toMillisecondsIntBound());
|
sslsock.setSoTimeout(handshakeTimeout.toMillisecondsIntBound());
|
||||||
}
|
}
|
||||||
|
|
||||||
prepareSocket(sslsock);
|
prepareSocket(sslsock, context);
|
||||||
|
|
||||||
if (LOG.isDebugEnabled()) {
|
if (LOG.isDebugEnabled()) {
|
||||||
LOG.debug("Enabled protocols: {}", (Object) sslsock.getEnabledProtocols());
|
LOG.debug("Enabled protocols: {}", (Object) sslsock.getEnabledProtocols());
|
||||||
|
|
Loading…
Reference in New Issue