hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Igor (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HTTPCLIENT-1522) SNI support
Date Thu, 26 Jun 2014 15:02:25 GMT

    [ https://issues.apache.org/jira/browse/HTTPCLIENT-1522?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14044732#comment-14044732
] 

Igor commented on HTTPCLIENT-1522:
----------------------------------

{code}
SSLContext sslcontext = SSLContexts.createSystemDefault();
      SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslcontext) {

        @Override
        public Socket connectSocket(int connectTimeout,
                                    Socket socket,
                                    HttpHost host,
                                    InetSocketAddress remoteAddress,
                                    InetSocketAddress localAddress,
                                    HttpContext context) throws IOException {
          if (socket instanceof SSLSocket) {
            try {
              PropertyUtils.setProperty(socket, "host", host.getHostName());
            }
            catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException
ex) {
            }
          }
          return super.connectSocket(connectTimeout,
                                     socket,
                                     host,
                                     remoteAddress,
                                     localAddress, context);
        }

      };

      CloseableHttpClient httpclient = HttpClients.custom().setSSLSocketFactory(sslsf).build();
      CloseableHttpResponse response=null;
      try {
        final String content = getContent(formData);
        String parametersForGet = url.toURI().toString() + (url.toURI().toString().indexOf("?")
> 0
                                                          ? content != null &&
                                                            content.trim().length() > 0
? "&" : ""
                                                          : "?") + content;
        HttpRequestBase requestBase = method == FormMethod.GET
                                      ? new HttpGet(parametersForGet)
                                      : new HttpPost(url.toURI());

        response = httpclient.execute(requestBase);
        HttpEntity entity = response.getEntity();
        System.err.println(""+entity);
      }
      catch (Exception ex){
        log.error("Cannot connect to url=[" + url + "]", ex);
      }
      finally {
        if (response!=null) try {
          response.close();
        }
        catch (IOException ex) {
          log.error(ex);
        }
      }
{code}

> SNI support
> -----------
>
>                 Key: HTTPCLIENT-1522
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1522
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpClient
>    Affects Versions: 4.3.4
>            Reporter: Igor
>
> Running HttpRequest to https://touchpoint.tealeaveshealth.com/consume
> causes an error
> {code}
> javax.net.ssl.SSLProtocolException: handshake alert:  unrecognized_name
> {code}
> to see how to fix, you can open *http://stackoverflow.com/questions/7615645/ssl-handshake-alert-unrecognized-name-error-since-upgrade-to-java-1-7-0*



--
This message was sent by Atlassian JIRA
(v6.2#6252)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Mime
View raw message