You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Billy Newman <ne...@gmail.com> on 2013/01/03 15:57:13 UTC

Set host name verifier for SystemDefaultHttpClient

Looking through the code I am have a hard time trying to understand
the easiest way to get a SystemDefaultHttpClient with the host name
verifier set to ALLOW_ALL_HOSTNAME_VERIFIER.

I have the following code:

SystemDefaultHttpClient client =  new SystemDefaultHttpClient();
SSLSocketFactory sf = SSLSocketFactory.getSystemSocketFactory();
sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
client.getConnectionManager().getSchemeRegistry().register(new
Scheme("https", 443, sf);

The problem with this is that the sf.setHostnameVerifier(...) is
depreciated.  Looking at the depreciation comments I do not see and
hints on what I should use to set the host name verifier.

I don't really want to duplicate all the code to pull in the system
properties to create  a 'System' SocketFactory, but I see no other way
to set the host name verifier.

Any ideas?

Thanks in advance!

Billy

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


Re: Set host name verifier for SystemDefaultHttpClient

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Thu, 2013-01-03 at 07:57 -0700, Billy Newman wrote:
> Looking through the code I am have a hard time trying to understand
> the easiest way to get a SystemDefaultHttpClient with the host name
> verifier set to ALLOW_ALL_HOSTNAME_VERIFIER.
> 
> I have the following code:
> 
> SystemDefaultHttpClient client =  new SystemDefaultHttpClient();
> SSLSocketFactory sf = SSLSocketFactory.getSystemSocketFactory();
> sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
> client.getConnectionManager().getSchemeRegistry().register(new
> Scheme("https", 443, sf);
> 
> The problem with this is that the sf.setHostnameVerifier(...) is
> depreciated.  Looking at the depreciation comments I do not see and
> hints on what I should use to set the host name verifier.
> 
> I don't really want to duplicate all the code to pull in the system
> properties to create  a 'System' SocketFactory, but I see no other way
> to set the host name verifier.
> 
> Any ideas?
> 
> Thanks in advance!
> 
> Billy
> 

It is not possible to choose a custom HostnameVerifier when using system
configuration. Please raise a change request in JIRA for this issue. For
the time being there is no way around using the deprecated setter
method.

Oleg 



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