2

I am using Apache HTTP Components HttpClient using the following code.

HttpAsyncClientBuilder builder = HttpAsyncClients.custom();
    builder.setConnectionManager(manager);
    builder.setRoutePlanner(planner)
            .setDefaultCredentialsProvider(provider);
    return builder.build();

And,

return new DefaultProxyRoutePlanner(new HttpHost("https", proxyHost, proxyPort));

The flow is like below, http client -> https proxy(with auth) -> https endpoint

The code makes a successful connection to the proxy but ends up with the below TLS error.

  .c.h.i.a.InternalAbstractHttpAsyncClient : ex-0000000001 preparing request execution
 o.a.h.c.h.p.RequestAddCookies            : ex-0000000001 Cookie spec selected: strict
 o.a.h.c.h.p.RequestAuthCache             : ex-0000000001 Re-using cached 'Basic' auth scheme for https://proxy.host:3128
 o.a.h.c.h.i.a.AsyncProtocolExec          : ex-0000000001 target auth state: UNCHALLENGED
 o.a.h.c.h.i.a.AsyncConnectExec           : ex-0000000001 acquiring connection with route {tls}->https://proxy.host:3128->https://api.host:443
 o.a.h.c.h.i.a.InternalHttpAsyncClient    : ex-0000000001 acquiring endpoint (3 MINUTES)
 .i.n.PoolingAsyncClientConnectionManager : ex-0000000001 endpoint lease request (3 MINUTES) [route: {tls}->https://proxy.host:3128->https://api.host:443][total available: 0; route allocated: 0 of 5; total allocated: 0 of 25]
 .i.n.PoolingAsyncClientConnectionManager : ex-0000000001 endpoint leased [route: {tls}->https://proxy.host:3128->https://api.host:443][total available: 0; route allocated: 1 of 5; total allocated: 1 of 25]
 .i.n.PoolingAsyncClientConnectionManager : ex-0000000001 acquired ep-0000000000
 o.a.h.c.h.i.a.InternalHttpAsyncClient    : ex-0000000001 acquired endpoint ep-0000000000
 o.a.h.c.h.i.a.InternalHttpAsyncClient    : ep-0000000000 connecting endpoint (3 MINUTES)
 .i.n.PoolingAsyncClientConnectionManager : ep-0000000000 connecting endpoint to https://proxy.host:3128 (3 MINUTES)
 .a.h.c.h.i.n.MultihomeIOSessionRequester : https://proxy.host:3128 resolving remote address
 .a.h.c.h.i.n.MultihomeIOSessionRequester : https://proxy.host:3128 resolved to [proxy.host/XX.XX.XX.XX, proxy.host/10.XX.XX.88]
 .a.h.c.h.i.n.MultihomeIOSessionRequester : https://proxy.host:3128 connecting null to proxy.host/XX.XX.XX.XX:3128 (3 MINUTES)
 o.a.h.c.r.IOSessionImpl                  : c-0000000000[ACTIVE][rc:c] protocol upgrade class org.apache.hc.core5.http2.impl.nio.ClientHttpProtocolNegotiator
 .a.h.c.h.i.n.MultihomeIOSessionRequester : https://proxy.host:3128 connected c-0000000000 /XXX.XX.XX.XXX:44774->proxy.host/XX.XX.XX.XX:3128
 .i.n.DefaultManagedAsyncClientConnection : c-0000000000 start TLS
 .i.n.PoolingAsyncClientConnectionManager : ep-0000000000 connected c-0000000000
 o.a.h.c.h.i.a.InternalHttpAsyncClient    : ep-0000000000 endpoint connected
 o.a.h.c.h.i.a.AsyncConnectExec           : ex-0000000001 connected to proxy
 o.a.h.c.h.i.a.AsyncConnectExec           : ex-0000000001 create tunnel
 o.a.h.c.h.i.a.HttpAsyncMainClientExec    : ex-0000000001 executing CONNECT api.host:443 HTTP/1.1
 o.a.h.c.h.i.a.InternalHttpAsyncClient    : ep-0000000000 start execution ex-0000000001
 .i.n.PoolingAsyncClientConnectionManager : ep-0000000000 executing exchange ex-0000000001 over c-0000000000
 .i.n.DefaultManagedAsyncClientConnection : c-0000000000 RequestExecutionCommand with NORMAL priority
 o.a.h.c.r.s.SSLIOSession                 : c-0000000000[ACTIVE][rwc:c][ACTIVE][rw][NOT_HANDSHAKING][0][0][0] Enqueued RequestExecutionCommand with priority IMMEDIATE
 o.a.h.c.r.s.SSLIOSession                 : c-0000000000[ACTIVE][rw:c][ACTIVE][rw][NOT_HANDSHAKING][0][0][0] Event cleared [c]
 o.a.h.c.r.s.SSLIOSession                 : c-0000000000[ACTIVE][r:r][ACTIVE][rw][NOT_HANDSHAKING][0][0][0] protocol upgrade class org.apache.hc.core5.http.impl.nio.ClientHttp1IOEventHandler
 o.a.h.c.h.i.a.HttpAsyncMainClientExec    : ex-0000000001 send request CONNECT api.host:443 HTTP/1.1, null entity
 o.a.h.c.h.headers                        : c-0000000000 >> CONNECT api.host:443 HTTP/1.1
 o.a.h.c.h.headers                        : c-0000000000 >> Host: api.host:443
 o.a.h.c.h.headers                        : c-0000000000 >> User-Agent: Apache-HttpAsyncClient/5.1.3 (Java/17.0.4)
 o.a.h.c.h.headers                        : c-0000000000 >> Proxy-Authorization: Basic <token>
 o.a.h.c.r.s.SSLIOSession                 : c-0000000000[ACTIVE][r:r][ACTIVE][rw][NOT_HANDSHAKING][0][0][347] 318 bytes written
 .
 .
 .
 o.a.h.c.r.s.SSLIOSession                 : c-0000000000[ACTIVE][r:r][ACTIVE][r][NOT_HANDSHAKING][68][39][0] 0 bytes read
 o.a.h.c.h.headers                        : c-0000000000 << HTTP/1.1 200 Connection established
 o.a.h.c.h.i.a.HttpAsyncMainClientExec    : ex-0000000001 consume response HTTP/1.1 200 Connection established,  null entity
 o.a.h.c.h.i.a.AsyncConnectExec           : ex-0000000001 tunnel to target created
 o.a.h.c.h.i.a.InternalHttpAsyncClient    : ep-0000000000 upgrading endpoint
 .i.n.DefaultManagedAsyncClientConnection : c-0000000000 start TLS
 o.a.h.c.h.i.a.HttpAsyncMainClientExec    : ex-0000000001 execution failed: TLS already activated
 .c.h.i.a.InternalAbstractHttpAsyncClient : ex-0000000001 request failed: TLS already activated
 .i.n.PoolingAsyncClientConnectionManager : ep-0000000000 close IMMEDIATE
 .i.n.DefaultManagedAsyncClientConnection : c-0000000000 Shutdown connection IMMEDIATE
 o.a.h.c.r.s.SSLIOSession                 : c-0000000000[ACTIVE][r:r][ACTIVE][r][NOT_HANDSHAKING][0][0][0] Close IMMEDIATE
 o.a.h.c.h.i.a.InternalHttpAsyncClient    : ep-0000000000 endpoint closed
 o.a.h.c.h.i.a.InternalHttpAsyncClient    : ep-0000000000 discarding endpoint
 .i.n.PoolingAsyncClientConnectionManager : ep-0000000000 releasing endpoint
 .i.n.PoolingAsyncClientConnectionManager : ep-0000000000 connection released [route: {tls}->https://proxy.host:3128->https://api.host:443][total available:0; route allocated: 0 of 5; total allocated: 0 of 25]

Any pointers on whats going on here and how to go about the above flow?

MPI
  • 47
  • 6
  • I have the same issue. for me, the apache HTTP client 5 sends an HTTP CONNECT to the proxy and the former does not support CONNECT. – Soufiane Roui Jan 05 '23 at 21:50

0 Answers0