HttpClientParams params = client.getParams();
params.setAuthenticationPreemptive(true);
client.setParams(params);
Credentials credentials = new UsernamePasswordCredentials(username, secret);
client.getState().setCredentials(AuthScope.ANY, credentials);
client.getHostConfiguration().setHost(host, 443, new Protocol("https", new SSLProtocolSocketFactory() {
@Override
public Socket createSocket(Socket socket, String s, int i, boolean b) throws IOException {
return Utils.createSSLContext().getSocketFactory().createSocket(socket, s, i, b);
}