public final static void main(final String[] args) throws Exception {
        try (CloseableHttpClient httpclient = HttpClients.createSystem()) {

            final HttpHost target = new HttpHost("https", "www.google.com");
            final HttpGet httpget = new HttpGet("https://www.google.ch/");

            System.out.println("Executing request " + httpget.getMethod() + " " + httpget.getUri());

            final HttpClientContext clientContext = HttpClientContext.create();
            httpclient.execute(target, httpget, clientContext, response -> {
                System.out.println("----------------------------------------");
                System.out.println(httpget + "->" + new StatusLine(response));
                EntityUtils.consume(response.getEntity());
                final SSLSession sslSession = clientContext.getSSLSession();
                if (sslSession != null) {
                    try {
                        System.out.println("Peer: " + sslSession.getPeerPrincipal());
                        System.out.println("TLS protocol: " + sslSession.getProtocol());
                        System.out.println("TLS cipher suite: " + sslSession.getCipherSuite());
                    } catch (final SSLPeerUnverifiedException ignore) {
                    }
                }
                return null;
            });
        }
    }
This example demonstrates how to use SNI to send requests to a virtual HTTPS
endpoint using the classic I/O.
httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientSNI.java