Re: How Do I Set SNI(Server Name Indentification)
I see no evidence of SNI not working: try (final CloseableHttpAsyncClient client = HttpAsyncClients.custom() .build()) { client.start(); final HttpHost endpoint = new HttpHost("https", InetAddress.getByName("www.google.com"), "www.google.ch", 443); final HttpClientContext clientContext = HttpClientContext.create(); final SimpleHttpRequest request = SimpleRequestBuilder.get() .setPath("/") .build(); System.out.println("Executing request " + request); final Future future = client.execute( endpoint, SimpleRequestProducer.create(request), SimpleResponseConsumer.create(), null, clientContext, new FutureCallback() { @Override public void completed(final SimpleHttpResponse response) { System.out.println(request + "->" + new StatusLine(response)); final SSLSession sslSession = clientContext.getSSLSession(); if (sslSession != null) { System.out.println("SSL protocol " + sslSession.getProtocol()); System.out.println("SSL cipher suite " + sslSession.getCipherSuite()); } System.out.println(response.getBody()); } @Override public void failed(final Exception ex) { System.out.println(request + "->" + ex); } @Override public void cancelled() { System.out.println(request + " cancelled"); } }); future.get(); System.out.println("Shutting down"); client.close(CloseMode.GRACEFUL); } Executing request GET / 2023-08-12 11:11:53,809 DEBUG [main][org.apache.hc.client5.http.impl.async.InternalAbstractHttpAsyncClient] ex-01 preparing request execution 2023-08-12 11:11:53,817 DEBUG [main][org.apache.hc.client5.http.impl.async.AsyncProtocolExec] ex-01 target auth state: UNCHALLENGED 2023-08-12 11:11:53,817 DEBUG [main][org.apache.hc.client5.http.impl.async.AsyncProtocolExec] ex-01 proxy auth state: UNCHALLENGED 2023-08-12 11:11:53,819 DEBUG [main][org.apache.hc.client5.http.impl.async.AsyncConnectExec] ex-01 acquiring connection with route {s}->https://www.google.ch:443 2023-08-12 11:11:53,819 DEBUG [main][org.apache.hc.client5.http.impl.async.InternalHttpAsyncClient] ex-01 acquiring endpoint (3 MINUTES) 2023-08-12 11:11:53,821 DEBUG [main][org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager] ex-01 endpoint lease request (3 MINUTES) [route: {s}->https://www.google.ch:443][total available: 0; route allocated: 0 of 5; total allocated: 0 of 25] 2023-08-12 11:11:53,823 DEBUG [main][org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager] ex-01 endpoint leased [route: {s}->https://www.google.ch:443][total available: 0; route allocated: 1 of 5; total allocated: 1 of 25] 2023-08-12 11:11:53,824 DEBUG [main][org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager] ex-01 acquired ep-01 2023-08-12 11:11:53,824 DEBUG [main][org.apache.hc.client5.http.impl.async.InternalHttpAsyncClient] ex-01 acquired endpoint ep-01 2023-08-12 11:11:53,824 DEBUG [main][org.apache.hc.client5.http.impl.async.InternalHttpAsyncClient] ep-01 connecting endpoint (null) 2023-08-12 11:11:53,825 DEBUG [main][org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager] ep-01 connecting endpoint to https://www.google.ch:443 (3 MINUTES) 2023-08-12 11:11:53,825 DEBUG [main][org.apache.hc.client5.http.impl.nio.MultihomeIOSessionRequester] www.google.ch:443 connecting null to www.google.com/142.250.184.68:443 (3 MINUTES) 2023-08-12 11:11:53,890 DEBUG [httpclient-dispatch-1][org.apache.hc.client5.http.impl.nio.DefaultManagedAsyncClientConnection] c-00 start TLS 2023-08-12 11:11:53,904 DEBUG [httpclient-dispatch-1][org.apache.hc.client5.http.ssl.AbstractClientTlsStrategy] Enabled protocols: [TLSv1.2] 2023-08-12 11:11:53,904 DEBUG [httpclient-dispatch-1][org.apache.hc.client5.http.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_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_RSA_WITH_AES_256_GCM_SHA384, TLS_DHE_DSS_WITH_AES_256_GCM_SHA384, 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_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_RSA_WITH_AES_256_CBC_SHA256, TLS_DHE_DSS_WITH_AES_256_CBC_SHA256, TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_DSS_WITH_AES_128_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384,
Re: How Do I Set SNI(Server Name Indentification)
Yes, like I already mentioned it is not a SNI problem. Because I was using PoolingAsyncClientConnectionManager I decided to replace it with PoolingHttpClientConnectionManager and it worked. So the problem is not in the SNI but in the PoolingAsyncClientConnectionManager. I am following this guide exactly: https://hc.apache.org/httpcomponents-client-5.2.x/migration-guide/migration-to-async-simple.html and I don't know what to do - I always get org.apache.hc.core5.util.TimeoutValueException. На сб, 12.08.2023 г. в 12:16 ч. Oleg Kalnichevski написа: > I see no evidence of SNI not working: > > try (final CloseableHttpAsyncClient client = HttpAsyncClients.custom() > .build()) { > > client.start(); > > final HttpHost endpoint = new HttpHost("https", InetAddress.getByName(" > www.google.com"), "www.google.ch", 443); > final HttpClientContext clientContext = HttpClientContext.create(); > > final SimpleHttpRequest request = SimpleRequestBuilder.get() > .setPath("/") > .build(); > > System.out.println("Executing request " + request); > final Future future = client.execute( > endpoint, > SimpleRequestProducer.create(request), > SimpleResponseConsumer.create(), > null, > clientContext, > new FutureCallback() { > > @Override > public void completed(final SimpleHttpResponse response) { > System.out.println(request + "->" + new > StatusLine(response)); > final SSLSession sslSession = > clientContext.getSSLSession(); > if (sslSession != null) { > System.out.println("SSL protocol " + > sslSession.getProtocol()); > System.out.println("SSL cipher suite " + > sslSession.getCipherSuite()); > } > System.out.println(response.getBody()); > } > > @Override > public void failed(final Exception ex) { > System.out.println(request + "->" + ex); > } > > @Override > public void cancelled() { > System.out.println(request + " cancelled"); > } > > }); > future.get(); > > System.out.println("Shutting down"); > client.close(CloseMode.GRACEFUL); > } > > Executing request GET / > 2023-08-12 11:11:53,809 DEBUG > [main][org.apache.hc.client5.http.impl.async.InternalAbstractHttpAsyncClient] > ex-01 preparing request execution > 2023-08-12 11:11:53,817 DEBUG > [main][org.apache.hc.client5.http.impl.async.AsyncProtocolExec] > ex-01 target auth state: UNCHALLENGED > 2023-08-12 11:11:53,817 DEBUG > [main][org.apache.hc.client5.http.impl.async.AsyncProtocolExec] > ex-01 proxy auth state: UNCHALLENGED > 2023-08-12 11:11:53,819 DEBUG > [main][org.apache.hc.client5.http.impl.async.AsyncConnectExec] > ex-01 acquiring connection with route {s}-> > https://www.google.ch:443 > 2023-08-12 11:11:53,819 DEBUG > [main][org.apache.hc.client5.http.impl.async.InternalHttpAsyncClient] > ex-01 acquiring endpoint (3 MINUTES) > 2023-08-12 11:11:53,821 DEBUG > [main][org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager] > ex-01 endpoint lease request (3 MINUTES) [route: {s}-> > https://www.google.ch:443][total available: 0; route allocated: 0 of 5; > total allocated: 0 of 25] > 2023-08-12 11:11:53,823 DEBUG > [main][org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager] > ex-01 endpoint leased [route: {s}->https://www.google.ch:443][total > available: 0; route allocated: 1 of 5; total allocated: 1 of 25] > 2023-08-12 11:11:53,824 DEBUG > [main][org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager] > ex-01 acquired ep-01 > 2023-08-12 11:11:53,824 DEBUG > [main][org.apache.hc.client5.http.impl.async.InternalHttpAsyncClient] > ex-01 acquired endpoint ep-01 > 2023-08-12 11:11:53,824 DEBUG > [main][org.apache.hc.client5.http.impl.async.InternalHttpAsyncClient] > ep-01 connecting endpoint (null) > 2023-08-12 11:11:53,825 DEBUG > [main][org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager] > ep-01 connecting endpoint to https://www.google.ch:443 (3 MINUTES) > 2023-08-12 11:11:53,825 DEBUG > [main][org.apache.hc.client5.http.impl.nio.MultihomeIOSessionRequester] > www.google.ch:443 connecting null to www.google.com/142.250.184.68:443 (3 > MINUTES) > 2023-08-12 11:11:53,890 DEBUG > [httpclient-dispatch-1][org.apache.hc.client5.http.impl.nio.DefaultManagedAsyncClientConnection] > c-00 start TLS > 2023-08-12 11:11:53,904 DEBUG > [httpclient-dispatch-1][org.apache.hc.client5.http.ssl.AbstractClientTlsStrategy] > Enabled protocols: [TLSv1.2] > 2023-08-12 11:11:53,904 DEBUG > [httpclient-dispatch-1][org.apache.hc.client5
Re: How Do I Set SNI(Server Name Indentification)
On Sat, 2023-08-12 at 12:27 +0300, Petar Tahchiev wrote: > Yes, > like I already mentioned it is not a SNI problem. > > Because I was using PoolingAsyncClientConnectionManager I decided to > replace it with PoolingHttpClientConnectionManager and it worked. So > the > problem is not in the SNI but in the > PoolingAsyncClientConnectionManager. I > am following this guide exactly: > https://hc.apache.org/httpcomponents-client-5.2.x/migration-guide/migration-to-async-simple.html > > and I don't know what to do - I always get > org.apache.hc.core5.util.TimeoutValueException. > > Petar No one, just no one here is going to debug your code for you. Please start with something very simple, something straight out of the migration guide, make sure it works, and gradually make it more complex, more specific to your particular application domain, step by step. If at any point things stop working, you likely know what the possible cause may be. Oleg - To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org For additional commands, e-mail: httpclient-users-h...@hc.apache.org