Category Archives: apache-fluent-api

Apache Fluent Executor unable use proxy authentication

I would like to use Apache Fluent Executor and CloseableHttpClient to use proxy server with authentication. The following code does not work when the proxy server is enabled with username/password. Once the username/password is disabled, I get the expected response.

I tried to use .auth(HttpHost,username, password) method but that does not work. Please let me know what I am missing here.

Boolean setProxy(String proxyHostName, String proxyPort, String proxyUserName, String proxyPassword) {

TrustManager[] trustAllCerts = new TrustManager[]{
    new X509TrustManager(){
    public[] getAcceptedIssuers() {
    return null;

public void checkClientTrusted(X509Certificate[] certs, String authType) {}
public void checkServerTrusted(X509Certificate[] certs, String authType) {}
SSLContext sc = SSLContext.getInstance("SSL");
sc.init(null, trustAllCerts, new SecureRandom());
HttpHost proxy = new HttpHost(proxyHostName, Integer.parseInt(proxyPort));
DefaultProxyRoutePlanner routePlanner = new DefaultProxyRoutePlanner(proxy);
CloseableHttpClient httpClient = HttpClients.custom().setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE).setSslcontext(sc).setRoutePlanner(routePlanner).build();

Executor executor = Executor.newInstance(httpClient)
    .auth(proxyUserName, proxyPassword);

log.debug("ABOUT TO EXECUTE A URL");
String str = executor.execute(Request.Get("")).returnContent().asString();
log.debug("####" + str + "@@@@");