elastic/elasticsearch-java

Error when connect without validating the certificates

masalinas opened this issue · 1 comments

Java API client version

8.7.1

Java version

17

Elasticsearch Version

8.5.1

Problem description

Elasticsearch deployed in minikube export elastic service with a proxy port-forward in the port 9200. These are my tests:

  1. From curl using localhost works OK:
$ curl -k -u elastic https://localhost:9200/patients_1000/_search
{
    "query": {
        "match_all": {}
    }
}
  1. From Java using kubernetes ingress (avib-elastic=localhost) works OK. In this case validating the certicates correctly.
ClientConfiguration.builder()
                    .connectedTo("avib-elastic:9200")		            		
		    .usingSsl(getSSLContext())
		    .withBasicAuth(username, password)		                    
		    .build();
  1. From Java adapter using localhost NOT works. In this case not validating the certificates because mi ca.crt localhost is not included. Is a similar as previous 1) user case using curl
ClientConfiguration.builder()
		    .connectedTo("localhost:9200" )
		    .withBasicAuth(username, password)	
		    .build();

Exception:

Caused by: org.apache.http.ConnectionClosedException: Connection is closed
	at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.endOfInput(HttpAsyncRequestExecutor.java:356) ~[httpcore-nio-4.4.16.jar:4.4.16]
	at org.apache.http.impl.nio.DefaultNHttpClientConnection.consumeInput(DefaultNHttpClientConnection.java:261) ~[httpcore-nio-4.4.16.jar:4.4.16]
	at org.apache.http.impl.nio.client.InternalIODispatch.onInputReady(InternalIODispatch.java:87) ~[httpasyncclient-4.1.5.jar:4.1.5]
	at org.apache.http.impl.nio.client.InternalIODispatch.onInputReady(InternalIODispatch.java:40) ~[httpasyncclient-4.1.5.jar:4.1.5]
	at org.apache.http.impl.nio.reactor.AbstractIODispatch.inputReady(AbstractIODispatch.java:114) ~[httpcore-nio-4.4.16.jar:4.4.16]
	at org.apache.http.impl.nio.reactor.BaseIOReactor.readable(BaseIOReactor.java:162) ~[httpcore-nio-4.4.16.jar:4.4.16]
	at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvent(AbstractIOReactor.java:337) ~[httpcore-nio-4.4.16.jar:4.4.16]
	at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvents(AbstractIOReactor.java:315) ~[httpcore-nio-4.4.16.jar:4.4.16]
	at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:276) ~[httpcore-nio-4.4.16.jar:4.4.16]
	at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:104) ~[httpcore-nio-4.4.16.jar:4.4.16]
	at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:591) ~[httpcore-nio-4.4.16.jar:4.4.16]

Hello! I'm sorry but ClientConfiguration is a spring-data-elasticsearch class, I suggest opening an issue on their repository if this error persists.