Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Invalid
-
5.0.3
-
None
-
openjdk 1.8.0_292
Description
rhttpclient5 jdk8(1.8.0_292) CloseableHttpAsyncClient Received fatal alert: protocol_version but CloseableHttpClient works well
httpclient5 async code:
// HttpContext httpContext = new BasicHttpContext(); BasicCookieStore cookie = new BasicCookieStore(); httpContext.setAttribute(HttpClientContext.COOKIE_STORE, cookie); SimpleHttpRequest request = SimpleHttpRequest.copy(new HttpPost("http://www.baidu.com")); final SSLContext sslcontext = CipherSuitesUtil.createSslContext(); final TlsStrategy tlsStrategy = new DefaultClientTlsStrategy(sslcontext); final PoolingAsyncClientConnectionManager connectionManager = PoolingAsyncClientConnectionManagerBuilder .create() .setTlsStrategy(tlsStrategy) .build(); IOReactorConfig ioConfig = IOReactorConfig.custom() .setSoKeepAlive(true) .setSoTimeout(Timeout.ofMilliseconds(5000)) .setIoThreadCount(4) .setSelectInterval(TimeValue.ofMilliseconds(500)) .build(); RequestConfig requestConfig = RequestConfig.custom() .setCookieSpec(StandardCookieSpec.RELAXED) .setConnectTimeout(Timeout.ofMilliseconds(5000)) .setResponseTimeout(Timeout.ofMilliseconds(5000)) .setRedirectsEnabled(true) .setMaxRedirects(10) .build(); HttpAsyncClientBuilder clientBuilder = HttpAsyncClients.custom() .setDefaultRequestConfig(requestConfig) .setRedirectStrategy(CustomRedirectStrategy.INSTANCE) .setConnectionManager(connectionManager) .setVersionPolicy(HttpVersionPolicy.FORCE_HTTP_1) .setIOReactorConfig(ioConfig); CloseableHttpAsyncClient client = clientBuilder.build(); client.start(); client.execute(request, httpContext, new FutureCallback<SimpleHttpResponse>() { @Override public void completed(SimpleHttpResponse result) { System.out.println(result.getCode()); } @Override public void failed(Exception ex) { ex.printStackTrace(); logger.info("{}", httpContext.getProtocolVersion()); } @Override public void cancelled() { System.out.println("cancelled"); } });
logs like this:
2021-04-29 16:01:07.688 DEBUG --- [ main] .c.h.i.a.InternalAbstractHttpAsyncClient : ex-00000001: preparing request execution 2021-04-29 16:01:08.015 DEBUG --- [ient-dispatch-2] org.apache.hc.client5.http.wire : c-0000000001 >> "User-Agent: Aliyun-PTS-Async/5.0.3 (Java/1.8.0_292)[\r][\n]" 2021-04-29 16:01:07.700 DEBUG --- [ main] o.a.h.c.http.protocol.RequestAddCookies : Cookie spec selected: relaxed 2021-04-29 16:01:07.706 DEBUG --- [ main] o.a.h.c.http.protocol.RequestAuthCache : Auth cache not set in the context 2021-04-29 16:01:07.706 DEBUG --- [ main] o.a.h.c.h.impl.async.AsyncProtocolExec : ex-00000001: target auth state: UNCHALLENGED 2021-04-29 16:01:07.707 DEBUG --- [ main] o.a.h.c.h.impl.async.AsyncProtocolExec : ex-00000001: proxy auth state: UNCHALLENGED 2021-04-29 16:01:07.708 DEBUG --- [ main] o.a.h.c.h.impl.async.AsyncConnectExec : ex-00000001: acquiring connection with route {}->http://www.baidu.com:80 2021-04-29 16:01:07.709 DEBUG --- [ main] o.a.h.c.h.i.a.InternalHttpAsyncClient : ex-00000001: acquiring endpoint (3 MINUTES) 2021-04-29 16:01:07.710 DEBUG --- [ main] .i.n.PoolingAsyncClientConnectionManager : ex-00000001: endpoint lease request (3 MINUTES) [route: {}->http://www.baidu.com:80][total available: 0; route allocated: 0 of 5; total allocated: 0 of 25] 2021-04-29 16:01:07.715 DEBUG --- [ main] .i.n.PoolingAsyncClientConnectionManager : ex-00000001: endpoint leased [route: {}->http://www.baidu.com:80][total available: 0; route allocated: 1 of 5; total allocated: 1 of 25] 2021-04-29 16:01:07.716 DEBUG --- [ main] .i.n.PoolingAsyncClientConnectionManager : ex-00000001: acquired ep-00000000 2021-04-29 16:01:07.716 DEBUG --- [ main] o.a.h.c.h.i.a.InternalHttpAsyncClient : ex-00000001: acquired endpoint ep-00000000 2021-04-29 16:01:07.717 DEBUG --- [ main] o.a.h.c.h.i.a.InternalHttpAsyncClient : ep-00000000: connecting endpoint (5000 MILLISECONDS) 2021-04-29 16:01:07.717 DEBUG --- [ main] .i.n.PoolingAsyncClientConnectionManager : ep-00000000: connecting endpoint to http://www.baidu.com:80 (5000 MILLISECONDS) 2021-04-29 16:01:07.718 DEBUG --- [ main] .a.h.c.h.i.n.MultihomeIOSessionRequester : http://www.baidu.com:80: resolving remote address 2021-04-29 16:01:07.720 DEBUG --- [ main] .a.h.c.h.i.n.MultihomeIOSessionRequester : http://www.baidu.com:80: resolved to [www.baidu.com/180.101.49.11, www.baidu.com/180.101.49.12] 2021-04-29 16:01:07.721 DEBUG --- [ main] .a.h.c.h.i.n.MultihomeIOSessionRequester : http://www.baidu.com:80: connecting null to www.baidu.com/180.101.49.11:80 (5000 MILLISECONDS) 2021-04-29 16:01:07.794 DEBUG --- [ient-dispatch-1] .a.h.c.h.i.n.MultihomeIOSessionRequester : http://www.baidu.com:80: connected c-0000000000 /30.225.16.84:52320->www.baidu.com/180.101.49.11:80 2021-04-29 16:01:07.795 DEBUG --- [ient-dispatch-1] .i.n.PoolingAsyncClientConnectionManager : ep-00000000: connected c-0000000000 2021-04-29 16:01:07.795 DEBUG --- [ient-dispatch-1] o.a.h.c.h.i.a.InternalHttpAsyncClient : ep-00000000: endpoint connected 2021-04-29 16:01:07.795 DEBUG --- [ient-dispatch-1] o.a.h.c.h.impl.async.AsyncConnectExec : ex-00000001: connected to target 2021-04-29 16:01:07.795 DEBUG --- [ient-dispatch-1] o.a.h.c.h.impl.async.AsyncConnectExec : ex-00000001: route fully established 2021-04-29 16:01:07.796 DEBUG --- [ient-dispatch-1] o.a.h.c.h.i.a.HttpAsyncMainClientExec : ex-00000001: executing POST / HTTP/1.1 2021-04-29 16:01:07.798 DEBUG --- [ient-dispatch-1] o.a.h.c.h.i.a.InternalHttpAsyncClient : ep-00000000: start execution ex-00000001 2021-04-29 16:01:07.798 DEBUG --- [ient-dispatch-1] .i.n.PoolingAsyncClientConnectionManager : ep-00000000: executing exchange ex-00000001 over c-0000000000 2021-04-29 16:01:07.800 DEBUG --- [ient-dispatch-1] .i.n.DefaultManagedAsyncClientConnection : c-0000000000: RequestExecutionCommand with NORMAL priority 2021-04-29 16:01:07.800 DEBUG --- [ient-dispatch-1] o.apache.hc.core5.reactor.IOSessionImpl : c-0000000000[ACTIVE][rwc:c] Enqueued RequestExecutionCommand with priority IMMEDIATE 2021-04-29 16:01:07.801 DEBUG --- [ient-dispatch-1] o.apache.hc.core5.reactor.IOSessionImpl : c-0000000000 c-0000000000[ACTIVE][rw:c]: Event cleared [c] 2021-04-29 16:01:07.813 DEBUG --- [ient-dispatch-1] o.a.h.c.h.i.a.HttpAsyncMainClientExec : ex-00000001: send request POST / HTTP/1.1, null entity 2021-04-29 16:01:07.814 DEBUG --- [ient-dispatch-1] org.apache.hc.client5.http.headers : c-0000000000 >> POST / HTTP/1.1 2021-04-29 16:01:07.814 DEBUG --- [ient-dispatch-1] org.apache.hc.client5.http.headers : c-0000000000 >> Host: www.baidu.com 2021-04-29 16:01:07.814 DEBUG --- [ient-dispatch-1] org.apache.hc.client5.http.headers : c-0000000000 >> Connection: keep-alive 2021-04-29 16:01:07.816 DEBUG --- [ient-dispatch-1] o.apache.hc.core5.reactor.IOSessionImpl : c-0000000000 c-0000000000[ACTIVE][rw:c]: 117 bytes written 2021-04-29 16:01:07.816 DEBUG --- [ient-dispatch-1] org.apache.hc.client5.http.wire : c-0000000000 >> "POST / HTTP/1.1[\r][\n]" 2021-04-29 16:01:07.816 DEBUG --- [ient-dispatch-1] org.apache.hc.client5.http.wire : c-0000000000 >> "Host: www.baidu.com[\r][\n]" 2021-04-29 16:01:07.816 DEBUG --- [ient-dispatch-1] org.apache.hc.client5.http.wire : c-0000000000 >> "Connection: keep-alive[\r][\n]" 2021-04-29 16:01:07.816 DEBUG --- [ient-dispatch-1] org.apache.hc.client5.http.wire : c-0000000000 >> "[\r][\n]" 2021-04-29 16:01:07.816 DEBUG --- [ient-dispatch-1] o.apache.hc.core5.reactor.IOSessionImpl : c-0000000000 c-0000000000[ACTIVE][rw:c]: Event set [w] 2021-04-29 16:01:07.817 DEBUG --- [ient-dispatch-1] o.apache.hc.core5.reactor.IOSessionImpl : c-0000000000 c-0000000000[ACTIVE][r:c]: Event cleared [w] 2021-04-29 16:01:07.830 DEBUG --- [ient-dispatch-1] o.apache.hc.core5.reactor.IOSessionImpl : c-0000000000 c-0000000000[ACTIVE][r:r]: 482 bytes read 2021-04-29 16:01:07.831 DEBUG --- [ient-dispatch-1] org.apache.hc.client5.http.wire : c-0000000000 << "HTTP/1.1 302 Found[\r][\n]" 2021-04-29 16:01:07.831 DEBUG --- [ient-dispatch-1] org.apache.hc.client5.http.wire : c-0000000000 << "Bdpagetype: 3[\r][\n]" 2021-04-29 16:01:07.831 DEBUG --- [ient-dispatch-1] org.apache.hc.client5.http.wire : c-0000000000 << "Connection: keep-alive[\r][\n]" 2021-04-29 16:01:07.831 DEBUG --- [ient-dispatch-1] org.apache.hc.client5.http.wire : c-0000000000 << "Content-Length: 154[\r][\n]" 2021-04-29 16:01:07.831 DEBUG --- [ient-dispatch-1] org.apache.hc.client5.http.wire : c-0000000000 << "Content-Type: text/html[\r][\n]" 2021-04-29 16:01:07.831 DEBUG --- [ient-dispatch-1] org.apache.hc.client5.http.wire : c-0000000000 << "Date: Thu, 29 Apr 2021 08:01:07 GMT[\r][\n]" 2021-04-29 16:01:07.831 DEBUG --- [ient-dispatch-1] org.apache.hc.client5.http.wire : c-0000000000 << "Location: https://www.baidu.com/search/error.html[\r][\n]" 2021-04-29 16:01:07.831 DEBUG --- [ient-dispatch-1] org.apache.hc.client5.http.wire : c-0000000000 << "Server: BWS/1.1[\r][\n]" 2021-04-29 16:01:07.831 DEBUG --- [ient-dispatch-1] org.apache.hc.client5.http.wire : c-0000000000 << "Set-Cookie: BDSVRTM=0; path=/[\r][\n]" 2021-04-29 16:01:07.831 DEBUG --- [ient-dispatch-1] org.apache.hc.client5.http.wire : c-0000000000 << "Traceid: 161968326706131343469958385445872604417[\r][\n]" 2021-04-29 16:01:07.831 DEBUG --- [ient-dispatch-1] org.apache.hc.client5.http.wire : c-0000000000 << "X-Ua-Compatible: IE=Edge,chrome=1[\r][\n]" 2021-04-29 16:01:07.831 DEBUG --- [ient-dispatch-1] org.apache.hc.client5.http.wire : c-0000000000 << "[\r][\n]" 2021-04-29 16:01:07.831 DEBUG --- [ient-dispatch-1] org.apache.hc.client5.http.wire : c-0000000000 << "<html>[\r][\n]" 2021-04-29 16:01:07.831 DEBUG --- [ient-dispatch-1] org.apache.hc.client5.http.wire : c-0000000000 << "<head><title>302 Found</title></head>[\r][\n]" 2021-04-29 16:01:07.832 DEBUG --- [ient-dispatch-1] org.apache.hc.client5.http.wire : c-0000000000 << "<body bgcolor="white">[\r][\n]" 2021-04-29 16:01:07.832 DEBUG --- [ient-dispatch-1] org.apache.hc.client5.http.wire : c-0000000000 << "<center><h1>302 Found</h1></center>[\r][\n]" 2021-04-29 16:01:07.832 DEBUG --- [ient-dispatch-1] org.apache.hc.client5.http.wire : c-0000000000 << "<hr><center>nginx</center>[\r][\n]" 2021-04-29 16:01:07.832 DEBUG --- [ient-dispatch-1] org.apache.hc.client5.http.wire : c-0000000000 << "</body>[\r][\n]" 2021-04-29 16:01:07.832 DEBUG --- [ient-dispatch-1] org.apache.hc.client5.http.wire : c-0000000000 << "</html>[\r][\n]" 2021-04-29 16:01:07.835 DEBUG --- [ient-dispatch-1] org.apache.hc.client5.http.headers : c-0000000000 << HTTP/1.1 302 Found 2021-04-29 16:01:07.835 DEBUG --- [ient-dispatch-1] org.apache.hc.client5.http.headers : c-0000000000 << Bdpagetype: 3 2021-04-29 16:01:07.836 DEBUG --- [ient-dispatch-1] org.apache.hc.client5.http.headers : c-0000000000 << Connection: keep-alive 2021-04-29 16:01:07.836 DEBUG --- [ient-dispatch-1] org.apache.hc.client5.http.headers : c-0000000000 << Content-Length: 154 2021-04-29 16:01:07.836 DEBUG --- [ient-dispatch-1] org.apache.hc.client5.http.headers : c-0000000000 << Content-Type: text/html 2021-04-29 16:01:07.836 DEBUG --- [ient-dispatch-1] org.apache.hc.client5.http.headers : c-0000000000 << Date: Thu, 29 Apr 2021 08:01:07 GMT 2021-04-29 16:01:07.836 DEBUG --- [ient-dispatch-1] org.apache.hc.client5.http.headers : c-0000000000 << Location: https://www.baidu.com/search/error.html 2021-04-29 16:01:07.836 DEBUG --- [ient-dispatch-1] org.apache.hc.client5.http.headers : c-0000000000 << Server: BWS/1.1 2021-04-29 16:01:07.836 DEBUG --- [ient-dispatch-1] org.apache.hc.client5.http.headers : c-0000000000 << Set-Cookie: BDSVRTM=0; path=/ 2021-04-29 16:01:07.836 DEBUG --- [ient-dispatch-1] org.apache.hc.client5.http.headers : c-0000000000 << Traceid: 161968326706131343469958385445872604417 2021-04-29 16:01:07.836 DEBUG --- [ient-dispatch-1] org.apache.hc.client5.http.headers : c-0000000000 << X-Ua-Compatible: IE=Edge,chrome=1 2021-04-29 16:01:07.837 DEBUG --- [ient-dispatch-1] o.a.h.c.h.i.a.HttpAsyncMainClientExec : ex-00000001: consume response HTTP/1.1 302 Found, entity len 154 2021-04-29 16:01:07.838 DEBUG --- [ient-dispatch-1] o.a.h.c.h.p.ResponseProcessCookies : Cookie accepted [BDSVRTM="0", domain:www.baidu.com, path:/, expiry:null] 2021-04-29 16:01:07.841 DEBUG --- [ient-dispatch-1] o.a.h.c.h.impl.async.AsyncRedirectExec : ex-00000001: redirect requested to location 'https://www.baidu.com/search/error.html' 2021-04-29 16:01:07.842 DEBUG --- [ient-dispatch-1] o.a.h.c.h.impl.async.AsyncRedirectExec : ex-00000001: resetting target auth state 2021-04-29 16:01:07.842 DEBUG --- [ient-dispatch-1] o.a.h.c.h.impl.async.AsyncRedirectExec : ex-00000001: redirecting to 'https://www.baidu.com/search/error.html' via {}->http://www.baidu.com:80 2021-04-29 16:01:07.844 DEBUG --- [ient-dispatch-1] o.a.h.c.h.i.a.HttpAsyncMainClientExec : ex-00000001: consume response data, len 154 bytes 2021-04-29 16:01:07.844 DEBUG --- [ient-dispatch-1] o.a.h.c.h.i.a.HttpAsyncMainClientExec : ex-00000001: end of response data 2021-04-29 16:01:07.844 DEBUG --- [ient-dispatch-1] o.a.h.c.h.i.a.InternalHttpAsyncClient : ep-00000000: releasing valid endpoint 2021-04-29 16:01:07.844 DEBUG --- [ient-dispatch-1] .i.n.PoolingAsyncClientConnectionManager : ep-00000000: releasing endpoint 2021-04-29 16:01:07.844 DEBUG --- [ient-dispatch-1] .i.n.PoolingAsyncClientConnectionManager : ep-00000000: connection c-0000000000 can be kept alive for 3 MINUTES 2021-04-29 16:01:07.845 DEBUG --- [ient-dispatch-1] .i.n.PoolingAsyncClientConnectionManager : ep-00000000: connection released [route: {}->http://www.baidu.com:80][total available: 1; route allocated: 1 of 5; total allocated: 1 of 25] 2021-04-29 16:01:07.845 DEBUG --- [ient-dispatch-1] o.a.h.c.http.protocol.RequestAddCookies : Cookie spec selected: relaxed 2021-04-29 16:01:07.851 DEBUG --- [ient-dispatch-1] o.a.h.c.http.protocol.RequestAddCookies : Cookie [name: BDSVRTM; value: 0; domain: www.baidu.com; path: /; expiry: null] match [(secure)www.baidu.com:443/search/error.html] 2021-04-29 16:01:07.851 DEBUG --- [ient-dispatch-1] o.a.h.c.http.protocol.RequestAuthCache : Auth cache not set in the context 2021-04-29 16:01:07.851 DEBUG --- [ient-dispatch-1] o.a.h.c.h.impl.async.AsyncProtocolExec : ex-00000001: target auth state: UNCHALLENGED 2021-04-29 16:01:07.851 DEBUG --- [ient-dispatch-1] o.a.h.c.h.impl.async.AsyncProtocolExec : ex-00000001: proxy auth state: UNCHALLENGED 2021-04-29 16:01:07.851 DEBUG --- [ient-dispatch-1] o.a.h.c.h.impl.async.AsyncConnectExec : ex-00000001: acquiring connection with route {s}->https://www.baidu.com:443 2021-04-29 16:01:07.851 DEBUG --- [ient-dispatch-1] o.a.h.c.h.i.a.InternalHttpAsyncClient : ex-00000001: acquiring endpoint (3 MINUTES) 2021-04-29 16:01:07.852 DEBUG --- [ient-dispatch-1] .i.n.PoolingAsyncClientConnectionManager : ex-00000001: endpoint lease request (3 MINUTES) [route: {s}->https://www.baidu.com:443][total available: 1; route allocated: 0 of 5; total allocated: 1 of 25] 2021-04-29 16:01:07.852 DEBUG --- [ient-dispatch-1] .i.n.PoolingAsyncClientConnectionManager : ex-00000001: endpoint leased [route: {s}->https://www.baidu.com:443][total available: 1; route allocated: 1 of 5; total allocated: 2 of 25] 2021-04-29 16:01:07.852 DEBUG --- [ient-dispatch-1] .i.n.PoolingAsyncClientConnectionManager : ex-00000001: acquired ep-00000001 2021-04-29 16:01:07.852 DEBUG --- [ient-dispatch-1] o.a.h.c.h.i.a.InternalHttpAsyncClient : ex-00000001: acquired endpoint ep-00000001 2021-04-29 16:01:07.852 DEBUG --- [ient-dispatch-1] o.a.h.c.h.i.a.InternalHttpAsyncClient : ep-00000001: connecting endpoint (5000 MILLISECONDS) 2021-04-29 16:01:07.852 DEBUG --- [ient-dispatch-1] .i.n.PoolingAsyncClientConnectionManager : ep-00000001: connecting endpoint to https://www.baidu.com:443 (5000 MILLISECONDS) 2021-04-29 16:01:07.852 DEBUG --- [ient-dispatch-1] .a.h.c.h.i.n.MultihomeIOSessionRequester : https://www.baidu.com:443: resolving remote address 2021-04-29 16:01:07.853 DEBUG --- [ient-dispatch-1] .a.h.c.h.i.n.MultihomeIOSessionRequester : https://www.baidu.com:443: resolved to [www.baidu.com/180.101.49.11, www.baidu.com/180.101.49.12] 2021-04-29 16:01:07.853 DEBUG --- [ient-dispatch-1] .a.h.c.h.i.n.MultihomeIOSessionRequester : https://www.baidu.com:443: connecting null to www.baidu.com/180.101.49.11:443 (5000 MILLISECONDS) 2021-04-29 16:01:07.853 DEBUG --- [ient-dispatch-1] o.apache.hc.core5.reactor.IOSessionImpl : c-0000000000 c-0000000000[ACTIVE][r:r]: Event set [r] 2021-04-29 16:01:07.853 DEBUG --- [ient-dispatch-1] o.a.h.c.h.i.a.InternalHttpAsyncClient : c-0000000000 Connection is kept alive 2021-04-29 16:01:07.868 DEBUG --- [ient-dispatch-2] .a.h.c.h.i.n.MultihomeIOSessionRequester : https://www.baidu.com:443: connected c-0000000001 /30.225.16.84:52321->www.baidu.com/180.101.49.11:443 2021-04-29 16:01:07.869 DEBUG --- [ient-dispatch-2] .i.n.DefaultManagedAsyncClientConnection : c-0000000001: start TLS 2021-04-29 16:01:07.881 DEBUG --- [ient-dispatch-2] .i.n.PoolingAsyncClientConnectionManager : ep-00000001: connected c-0000000001 2021-04-29 16:01:07.881 DEBUG --- [ient-dispatch-2] o.a.h.c.h.i.a.InternalHttpAsyncClient : ep-00000001: endpoint connected 2021-04-29 16:01:07.881 DEBUG --- [ient-dispatch-2] o.a.h.c.h.impl.async.AsyncConnectExec : ex-00000001: connected to target 2021-04-29 16:01:07.882 DEBUG --- [ient-dispatch-2] o.a.h.c.h.impl.async.AsyncConnectExec : ex-00000001: route fully established 2021-04-29 16:01:07.882 DEBUG --- [ient-dispatch-2] o.a.h.c.h.i.a.HttpAsyncMainClientExec : ex-00000001: executing GET /search/error.html HTTP/1.1 2021-04-29 16:01:07.882 DEBUG --- [ient-dispatch-2] o.a.h.c.h.i.a.InternalHttpAsyncClient : ep-00000001: start execution ex-00000001 2021-04-29 16:01:07.882 DEBUG --- [ient-dispatch-2] .i.n.PoolingAsyncClientConnectionManager : ep-00000001: executing exchange ex-00000001 over c-0000000001 2021-04-29 16:01:07.882 DEBUG --- [ient-dispatch-2] .i.n.DefaultManagedAsyncClientConnection : c-0000000001: RequestExecutionCommand with NORMAL priority 2021-04-29 16:01:07.883 DEBUG --- [ient-dispatch-2] o.a.hc.core5.reactor.ssl.SSLIOSession : c-0000000001[ACTIVE][rwc:c][ACTIVE][rw][NOT_HANDSHAKING][0][0][0] Enqueued RequestExecutionCommand with priority IMMEDIATE 2021-04-29 16:01:07.883 DEBUG --- [ient-dispatch-2] o.a.hc.core5.reactor.ssl.SSLIOSession : c-0000000001 c-0000000001[ACTIVE][rw:c][ACTIVE][rw][NOT_HANDSHAKING][0][0][0]: Event cleared [c] 2021-04-29 16:01:07.886 DEBUG --- [ient-dispatch-2] o.a.h.c.h.ssl.AbstractClientTlsStrategy : Enabled protocols: [TLSv1.2] 2021-04-29 16:01:07.886 DEBUG --- [ient-dispatch-2] o.a.h.c.h.ssl.AbstractClientTlsStrategy : Enabled cipher suites:[TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, TLS_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384, TLS_DHE_RSA_WITH_AES_256_GCM_SHA384, TLS_DHE_DSS_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_DSS_WITH_AES_128_GCM_SHA256, TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384, TLS_RSA_WITH_AES_256_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384, TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384, TLS_DHE_RSA_WITH_AES_256_CBC_SHA256, TLS_DHE_DSS_WITH_AES_256_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDH_RSA_WITH_AES_256_CBC_SHA, TLS_DHE_RSA_WITH_AES_256_CBC_SHA, TLS_DHE_DSS_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_DSS_WITH_AES_128_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, TLS_EMPTY_RENEGOTIATION_INFO_SCSV] 2021-04-29 16:01:08.009 DEBUG --- [ient-dispatch-2] o.a.h.c.h.ssl.AbstractClientTlsStrategy : Secure session established 2021-04-29 16:01:08.009 DEBUG --- [ient-dispatch-2] o.a.h.c.h.ssl.AbstractClientTlsStrategy : negotiated protocol: TLSv1.2 2021-04-29 16:01:08.010 DEBUG --- [ient-dispatch-2] o.a.h.c.h.ssl.AbstractClientTlsStrategy : negotiated cipher suite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 2021-04-29 16:01:08.010 DEBUG --- [ient-dispatch-2] o.a.h.c.h.ssl.AbstractClientTlsStrategy : peer principal: CN=baidu.com, O="Beijing Baidu Netcom Science Technology Co., Ltd", OU=service operation department, L=beijing, ST=beijing, C=CN 2021-04-29 16:01:08.010 DEBUG --- [ient-dispatch-2] o.a.h.c.h.ssl.AbstractClientTlsStrategy : peer alternative names: [baidu.com, baifubao.com, www.baidu.cn, www.baidu.com.cn, mct.y.nuomi.com, apollo.auto, dwz.cn, *.baidu.com, *.baifubao.com, *.baidustatic.com, *.bdstatic.com, *.bdimg.com, *.hao123.com, *.nuomi.com, *.chuanke.com, *.trustgo.com, *.bce.baidu.com, *.eyun.baidu.com, *.map.baidu.com, *.mbd.baidu.com, *.fanyi.baidu.com, *.baidubce.com, *.mipcdn.com, *.news.baidu.com, *.baidupcs.com, *.aipage.com, *.aipage.cn, *.bcehost.com, *.safe.baidu.com, *.im.baidu.com, *.baiducontent.com, *.dlnel.com, *.dlnel.org, *.dueros.baidu.com, *.su.baidu.com, *.91.com, *.hao123.baidu.com, *.apollo.auto, *.xueshu.baidu.com, *.bj.baidubce.com, *.gz.baidubce.com, *.smartapps.cn, *.bdtjrcv.com, *.hao222.com, *.haokan.com, *.pae.baidu.com, *.vd.bdstatic.com, click.hm.baidu.com, log.hm.baidu.com, cm.pos.baidu.com, wn.pos.baidu.com, update.pan.baidu.com] 2021-04-29 16:01:08.010 DEBUG --- [ient-dispatch-2] o.a.h.c.h.ssl.AbstractClientTlsStrategy : issuer principal: CN=GlobalSign Organization Validation CA - SHA256 - G2, O=GlobalSign nv-sa, C=BE 2021-04-29 16:01:08.013 DEBUG --- [ient-dispatch-2] o.a.h.c.h.i.a.HttpAsyncMainClientExec : ex-00000001: send request GET /search/error.html HTTP/1.1, null entity 2021-04-29 16:01:08.014 DEBUG --- [ient-dispatch-2] org.apache.hc.client5.http.headers : c-0000000001 >> GET /search/error.html HTTP/1.1 2021-04-29 16:01:08.014 DEBUG --- [ient-dispatch-2] org.apache.hc.client5.http.headers : c-0000000001 >> Cookie: BDSVRTM=0 2021-04-29 16:01:08.014 DEBUG --- [ient-dispatch-2] org.apache.hc.client5.http.headers : c-0000000001 >> Host: www.baidu.com 2021-04-29 16:01:08.014 DEBUG --- [ient-dispatch-2] org.apache.hc.client5.http.headers : c-0000000001 >> Connection: keep-alive 2021-04-29 16:01:08.014 DEBUG --- [ient-dispatch-2] o.a.hc.core5.reactor.ssl.SSLIOSession : c-0000000001 c-0000000001[ACTIVE][r:r][ACTIVE][rw][NOT_HANDSHAKING][0][0][0]: 152 bytes written 2021-04-29 16:01:08.014 DEBUG --- [ient-dispatch-2] org.apache.hc.client5.http.wire : c-0000000001 >> "GET /search/error.html HTTP/1.1[\r][\n]" 2021-04-29 16:01:08.015 DEBUG --- [ient-dispatch-2] org.apache.hc.client5.http.wire : c-0000000001 >> "Cookie: BDSVRTM=0[\r][\n]" 2021-04-29 16:01:08.015 DEBUG --- [ient-dispatch-2] org.apache.hc.client5.http.wire : c-0000000001 >> "Host: www.baidu.com[\r][\n]" 2021-04-29 16:01:08.015 DEBUG --- [ient-dispatch-2] org.apache.hc.client5.http.wire : c-0000000001 >> "Connection: keep-alive[\r][\n]" 2021-04-29 16:01:08.015 DEBUG --- [ient-dispatch-2] org.apache.hc.client5.http.wire : c-0000000001 >> "[\r][\n]" 2021-04-29 16:01:08.015 DEBUG --- [ient-dispatch-2] o.a.hc.core5.reactor.ssl.SSLIOSession : c-0000000001 c-0000000001[ACTIVE][rw:r][ACTIVE][rw][NOT_HANDSHAKING][0][0][0]: Event set [w] 2021-04-29 16:01:08.015 DEBUG --- [ient-dispatch-2] o.a.hc.core5.reactor.ssl.SSLIOSession : c-0000000001 c-0000000001[ACTIVE][r:r][ACTIVE][r][NOT_HANDSHAKING][0][0][0]: Event cleared [w] 2021-04-29 16:01:08.034 DEBUG --- [ient-dispatch-2] o.a.h.c.h.i.a.HttpAsyncMainClientExec : ex-00000001: execution failed: Received fatal alert: protocol_version 2021-04-29 16:01:08.034 DEBUG --- [ient-dispatch-2] .c.h.i.a.InternalAbstractHttpAsyncClient : ex-00000001: request failed: Received fatal alert: protocol_version 2021-04-29 16:01:08.034 DEBUG --- [ient-dispatch-2] .i.n.PoolingAsyncClientConnectionManager : ep-00000001: close IMMEDIATE 2021-04-29 16:01:08.034 DEBUG --- [ient-dispatch-2] .i.n.DefaultManagedAsyncClientConnection : c-0000000001: Shutdown connection IMMEDIATE 2021-04-29 16:01:08.035 DEBUG --- [ient-dispatch-2] o.a.hc.core5.reactor.ssl.SSLIOSession : c-0000000001 c-0000000001[CLOSED][][CLOSED][r][NOT_HANDSHAKING][inbound done][][outbound done][][31][0][0]: Close IMMEDIATE 2021-04-29 16:01:08.035 DEBUG --- [ient-dispatch-2] o.a.h.c.h.i.a.InternalHttpAsyncClient : ep-00000001: endpoint closed 2021-04-29 16:01:08.035 DEBUG --- [ient-dispatch-2] o.a.h.c.h.i.a.InternalHttpAsyncClient : ep-00000001: discarding endpoint 2021-04-29 16:01:08.035 DEBUG --- [ient-dispatch-2] .i.n.PoolingAsyncClientConnectionManager : ep-00000001: releasing endpoint 2021-04-29 16:01:08.035 DEBUG --- [ient-dispatch-2] .i.n.PoolingAsyncClientConnectionManager : ep-00000001: connection released [route: {s}->https://www.baidu.com:443][total available: 1; route allocated: 0 of 5; total allocated: 1 of 25] 2021-04-29 16:01:08.036 INFO --- [ient-dispatch-2] c.t.a.allspark.agent.util.HttpUtilTest : HTTP/1.1 2021-04-29 16:01:08.036 DEBUG --- [ient-dispatch-2] o.a.hc.core5.reactor.ssl.SSLIOSession : c-0000000001 c-0000000001[CLOSED][][CLOSED][r][NOT_HANDSHAKING][inbound done][][outbound done][][31][0][0]: Close IMMEDIATE javax.net.ssl.SSLHandshakeException: Received fatal alert: protocol_version at sun.security.ssl.Alert.createSSLException(Alert.java:131) at sun.security.ssl.Alert.createSSLException(Alert.java:117) at sun.security.ssl.TransportContext.fatal(TransportContext.java:311) at sun.security.ssl.Alert$AlertConsumer.consume(Alert.java:293) at sun.security.ssl.TransportContext.dispatch(TransportContext.java:185) at sun.security.ssl.SSLTransport.decode(SSLTransport.java:152) at sun.security.ssl.SSLEngineImpl.decode(SSLEngineImpl.java:575) at sun.security.ssl.SSLEngineImpl.readRecord(SSLEngineImpl.java:531) at sun.security.ssl.SSLEngineImpl.unwrap(SSLEngineImpl.java:398) at sun.security.ssl.SSLEngineImpl.unwrap(SSLEngineImpl.java:377) at javax.net.ssl.SSLEngine.unwrap(SSLEngine.java:626) at org.apache.hc.core5.reactor.ssl.SSLIOSession.doUnwrap(SSLIOSession.java:288) at org.apache.hc.core5.reactor.ssl.SSLIOSession.decryptData(SSLIOSession.java:543) at org.apache.hc.core5.reactor.ssl.SSLIOSession.access$400(SSLIOSession.java:72) at org.apache.hc.core5.reactor.ssl.SSLIOSession$1.inputReady(SSLIOSession.java:172) at org.apache.hc.core5.reactor.InternalDataChannel.onIOEvent(InternalDataChannel.java:131) at org.apache.hc.core5.reactor.InternalChannel.handleIOEvent(InternalChannel.java:51) at org.apache.hc.core5.reactor.SingleCoreIOReactor.processEvents(SingleCoreIOReactor.java:179) at org.apache.hc.core5.reactor.SingleCoreIOReactor.doExecute(SingleCoreIOReactor.java:128) at org.apache.hc.core5.reactor.AbstractSingleCoreIOReactor.execute(AbstractSingleCoreIOReactor.java:85) at org.apache.hc.core5.reactor.IOReactorWorker.run(IOReactorWorker.java:44) at java.lang.Thread.run(Thread.java:748)
When I use this code, it works well
//java sslcontext = CipherSuitesUtil.createSslContext(); final SSLConnectionSocketFactory sslSocketFactory = SSLConnectionSocketFactoryBuilder.create() .setSslContext(sslcontext) .build(); final HttpClientConnectionManager cm = PoolingHttpClientConnectionManagerBuilder.create() .setSSLSocketFactory(sslSocketFactory) .build(); try (CloseableHttpClient httpclient = HttpClients.custom() .setConnectionManager(cm) .build()) { final HttpPost httpget = new HttpPost("https://www.baidu.com/"); System.out.println("Executing request " + httpget.getMethod() + " " + httpget.getUri()); final HttpClientContext clientContext = HttpClientContext.create(); try (CloseableHttpResponse response = httpclient.execute(httpget, clientContext)) { logger.info("----------------------------------------"); logger.info(response.getCode() + " " + response.getReasonPhrase()); logger.info("body: {}", IOUtils.toString(response.getEntity().getContent())); final SSLSession sslSession = clientContext.getSSLSession(); if (sslSession != null) { System.out.println("SSL protocol " + sslSession.getProtocol()); System.out.println("SSL cipher suite " + sslSession.getCipherSuite()); } } }
I've tried Apache HTTP Client 5.0 HTTP/2 POST Example needed this, upgrade jdk8 to jdk8(1.8.0_292), and install jce, but still not work. really need some help.And also I checked this, seems TLSV1.2 and TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 is ok.