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);
        } else {
            sslsock.setEnabledProtocols(TLS.excludeWeak(sslsock.getEnabledProtocols()));
        }
        if (supportedCipherSuites != null) {
            sslsock.setEnabledCipherSuites(supportedCipherSuites);
        } else {
            sslsock.setEnabledCipherSuites(TlsCiphers.excludeWeak(sslsock.getEnabledCipherSuites()));
        }
        final Timeout handshakeTimeout = tlsConfig.getHandshakeTimeout();
        if (handshakeTimeout != null) {
            sslsock.setSoTimeout(handshakeTimeout.toMillisecondsIntBound());
        }

        prepareSocket(sslsock, context);

        if (LOG.isDebugEnabled()) {
            LOG.debug("Enabled protocols: {}", (Object) sslsock.getEnabledProtocols());
            LOG.debug("Enabled cipher suites: {}", (Object) sslsock.getEnabledCipherSuites());
            LOG.debug("Starting handshake ({})", handshakeTimeout);
        }
        sslsock.startHandshake();
        verifyHostname(sslsock, target);
    }
Connects the socket to the target host with the given resolved remote address using
{@link Socket#connect(SocketAddress, int)}. This method may be overridden to customize
how precisely {@link Socket#connect(SocketAddress, int)} is handled without impacting
other connection establishment code within {@link #executeHandshake(SSLSocket, String, Object, HttpContext)},
for example.

@param sock the socket to connect.
@param remoteAddress the resolved remote address to connect to.
@param connectTimeout connect timeout.
@param context the actual HTTP context.
@throws IOException if an I/O error occurs
httpclient5/src/main/java/org/apache/hc/client5/http/ssl/SSLConnectionSocketFactory.java