title: How do I force Apache's CloseableHttpClient to use TLSv1.2?
body: <p>In Java, I need to get the Apache CloseableHttpClient to use TLSv1.2. Currently it looks like it uses HTTP/1.1. How can I specify the protocol version in the code below?</p>
  
  <pre><code> public static void main(String [] args){
                                  try {
                        SSLContext sslContext = SSLContext.getInstance("TLS");
                                    @SuppressWarnings("static-access")
                                    CloseableHttpClient httpclient = HttpClientBuilder.create()
                                      .setSSLSocketFactory(new SSLConnectionSocketFactory(sslContext.getDefault(), new String[] { "TLSv1.2" }, null, SSLConnectionSocketFactory.getDefaultHostnameVerifier()))
                                      .build();
                        HttpHost target = new HttpHost("https://www.sometest.com", 443, "https");
                        String call = "/vivisimo/cgi-bin/velocity";
                        HttpGet getRequest = new HttpGet(call);
                        System.out.println("Protocol Version:" + getRequest.getProtocolVersion());
                       } catch (Exception e) {
                        e.printStackTrace();
                                    }
  }
  </code></pre>