private void executeHandshake(
            final SSLSocket upgradedSocket,
            final String target,
            final Object attachment) throws IOException {
        final TlsConfig tlsConfig = attachment instanceof TlsConfig ? (TlsConfig) attachment : TlsConfig.DEFAULT;

        final SSLParameters sslParameters = upgradedSocket.getSSLParameters();
        if (supportedProtocols != null) {
            sslParameters.setProtocols(supportedProtocols);
        } else {
            sslParameters.setProtocols(TLS.excludeWeak(upgradedSocket.getEnabledProtocols()));
        }
        if (supportedCipherSuites != null) {
            sslParameters.setCipherSuites(supportedCipherSuites);
        } else {
            sslParameters.setCipherSuites(TlsCiphers.excludeWeak(upgradedSocket.getEnabledCipherSuites()));
        }
        if (hostnameVerificationPolicy == HostnameVerificationPolicy.BUILTIN || hostnameVerificationPolicy == HostnameVerificationPolicy.BOTH) {
            sslParameters.setEndpointIdentificationAlgorithm(URIScheme.HTTPS.id);
        }
        upgradedSocket.setSSLParameters(sslParameters);

        final Timeout handshakeTimeout = tlsConfig.getHandshakeTimeout();
        if (handshakeTimeout != null) {
            upgradedSocket.setSoTimeout(handshakeTimeout.toMillisecondsIntBound());
        }

        initializeSocket(upgradedSocket);

        if (LOG.isDebugEnabled()) {
            LOG.debug("Enabled protocols: {}", (Object) upgradedSocket.getEnabledProtocols());
            LOG.debug("Enabled cipher suites: {}", (Object) upgradedSocket.getEnabledCipherSuites());
            LOG.debug("Starting handshake ({})", handshakeTimeout);
        }
        upgradedSocket.startHandshake();
        verifySession(target, upgradedSocket.getSession());
    }
@deprecated use {@link #upgrade(TransportSecurityLayer, NamedEndpoint, Object, Timeout, FutureCallback)}
httpclient5/src/main/java/org/apache/hc/client5/http/ssl/AbstractClientTlsStrategy.java