You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2023/01/04 14:36:48 UTC

[httpcomponents-client] branch master updated: Pass HttpContext to SSLConnectionSocketFactory#prepareSocket method (#404)

This is an automated email from the ASF dual-hosted git repository.

olegk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/httpcomponents-client.git


The following commit(s) were added to refs/heads/master by this push:
     new d2016eaac Pass HttpContext to SSLConnectionSocketFactory#prepareSocket method (#404)
d2016eaac is described below

commit d2016eaacf31c0de4b2ca788d74e65c18c5fc8d7
Author: Alen Turkovic <al...@gmail.com>
AuthorDate: Wed Jan 4 15:36:42 2023 +0100

    Pass HttpContext to SSLConnectionSocketFactory#prepareSocket method (#404)
---
 .../http/ssl/SSLConnectionSocketFactory.java       | 23 +++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/SSLConnectionSocketFactory.java b/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/SSLConnectionSocketFactory.java
index 03a7aa6a5..cf08329f2 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/SSLConnectionSocketFactory.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/SSLConnectionSocketFactory.java
@@ -178,6 +178,13 @@ public class SSLConnectionSocketFactory implements LayeredConnectionSocketFactor
         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
      * (before the SSL handshake happens).
@@ -186,7 +193,9 @@ public class SSLConnectionSocketFactory implements LayeredConnectionSocketFactor
      * call {@link javax.net.ssl.SSLSocket#setEnabledCipherSuites(String[])}.
      * @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
@@ -245,7 +254,7 @@ public class SSLConnectionSocketFactory implements LayeredConnectionSocketFactor
         // Setup SSL layering if necessary
         if (sock instanceof SSLSocket) {
             final SSLSocket sslsock = (SSLSocket) sock;
-            executeHandshake(sslsock, host.getHostName(), attachment);
+            executeHandshake(sslsock, host.getHostName(), attachment, context);
             return sock;
         }
         return createLayeredSocket(sock, host.getHostName(), remoteAddress.getPort(), attachment, context);
@@ -272,11 +281,15 @@ public class SSLConnectionSocketFactory implements LayeredConnectionSocketFactor
                 target,
                 port,
                 true);
-        executeHandshake(sslsock, target, attachment);
+        executeHandshake(sslsock, target, attachment, context);
         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;
         if (supportedProtocols != null) {
             sslsock.setEnabledProtocols(supportedProtocols);
@@ -293,7 +306,7 @@ public class SSLConnectionSocketFactory implements LayeredConnectionSocketFactor
             sslsock.setSoTimeout(handshakeTimeout.toMillisecondsIntBound());
         }
 
-        prepareSocket(sslsock);
+        prepareSocket(sslsock, context);
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("Enabled protocols: {}", (Object) sslsock.getEnabledProtocols());