hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: SSL and stale check changes
Date Wed, 01 Apr 2015 14:50:36 GMT
On Wed, 2015-04-01 at 15:50 +0200, Joan Balagueró wrote:
> Hello,
> 
>  
> 
> I’ve just installed HC4.4.1 and some methods related to ssl are deprecated.
> Concretely this piece of code:
> 
>  
> 
>    SSLContext sslContext = SSLContexts.custom().useTLS().build();
> 
>    sslContext.init(keyManagers, null, null);
> 
>  
> 
>    return (new SSLConnectionSocketFactory(sslContext,
> SSLConnectionSocketFactory.STRICT_HOSTNAME_VERIFIER));
> 
>  
> 
> 
> 
> But taking a look at the HC4.4. documentation, section 2.7.3., I still see
> this way of building a SSLContext.
> 
>  
> 
> Which methods should I use now? Maybe the SSLContexts.createSystemDefault()?
> Does this method create a SSLContext with TLS like the previous one? And how
> can I create a SSLConnectionFactory with strict hostname verifier?
> 
>  

SSLContext builders are now provided by HttpCore and should be imported
from 'org.apache.http.ssl' instead of 'org.apache.http.conn.ssl' 

> 
> Furthermore, the following method is also deprecated:
> 
>  
> 
>   this.rc = RequestConfig.custom().setAuthenticationEnabled(false).
> 
>  
> setConnectionRequestTimeout(1).
> 
>  
> setConnectTimeout(this.connectionTimeout).
> 
>  
> setSocketTimeout(this.responseTimeout).
> 
>  
> setExpectContinueEnabled(false).
> 
>  
> setStaleConnectionCheckEnabled(false).
> 
>                                                 setRedirectsEnabled(false).
> 
>                                                         build();
> 
>  
> 
> I know that stale checking has been improved in this version, but how can I
> use it?
> 

PoolingHttpClientConnectionManager cm = new
PoolingHttpClientConnectionManager();
cm.setValidateAfterInactivity(1000);
CloseableHttpClient client = HttpClients.custom()
        .setConnectionManager(cm)
        .build();

Hope this helps

Oleg



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


Mime
View raw message