*
* @return the HTTP client.
*/
private DefaultHttpClient createHttpClient()
{
DefaultHttpClient httpClient = new DefaultHttpClient();
try
{
// make sure we use Certificate Verification Service if
// for some reason the certificate needs to be shown to user
// for approval
ClientConnectionManager ccm = httpClient.getConnectionManager();
SchemeRegistry sr = ccm.getSchemeRegistry();
SSLContext ctx = certificateVerification.getSSLContext(
uri.getHost(), uri.getPort() == -1 ? 443 : uri.getPort());
org.apache.http.conn.ssl.SSLSocketFactory ssf
= new org.apache.http.conn.ssl.SSLSocketFactory(
ctx, new HostNameResolverImpl());
ssf.setHostnameVerifier(org.apache.http.conn.ssl.SSLSocketFactory
.ALLOW_ALL_HOSTNAME_VERIFIER);
sr.register(new Scheme("https", ssf, 443));
}
catch(Throwable e)
{
logger.error("Cannot add our trust manager to httpClient", e);
}
HttpParams httpParams = httpClient.getParams();
HttpConnectionParams.setConnectionTimeout(httpParams, timeout);
HttpConnectionParams.setSoTimeout(httpParams, timeout);
return httpClient;
}