Elaticsearch SQL CLI is not working

Hi Team,

I am trying to execute some sql commands from SQL CLI in elasticsearch -8.8.2 but while executing below commands to open SQL CLI

./bin/elasticsearch-sql-cli

I am getting below error
ERROR: Cannot communicate with the server http://localhost:9200/. This version of CLI only works with Elasticsearch version 8.8.2

below assist me regarding the same

I'm surprised that it tries to connect to http instead of https.

I have tried with https also using below command
./bin/elasticsearch-sql-cli https://localhost:9200/
but getting below error
ERROR: Cannot communicate with the server https://localhost:9200/. This version of CLI only works with Elasticsearch version 8.8.2

What is the output of:

GET /

{
"name": "node-1",
"cluster_name": "my-application",
"cluster_uuid": "PdxPNKJfRUOh-nJVi4R9jw",
"version": {
"number": "8.8.2",
"build_flavor": "default",
"build_type": "zip",
"build_hash": "98e1271edf932a480e4262a471281f1ee295ce6b",
"build_date": "2023-06-26T05:16:16.196344851Z",
"build_snapshot": false,
"lucene_version": "9.6.0",
"minimum_wire_compatibility_version": "7.17.0",
"minimum_index_compatibility_version": "7.0.0"
},
"tagline": "You Know, for Search"
}

What is your OS and what is the version?

Windows 11 Enterprise

I'm afraid I don't have that version at hand...
I can see in the code that there is a -d option.

Could you try with it?

after executing ./bin/elasticsearch-sql-cli https://localhost:9200/ -d command ,I am getting below error, Please provide the solutions for below error .

org.elasticsearch.xpack.sql.client.ClientException: Cannot POST address https://localhost:9200/?error_trace (PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target)

Is it the full output? Could you share the full output please?

Anyway, I think that there might be a JVM issue. Like a wrong one is used. It's supposed to use the one in %ES_HOME%\jdk\bin\java.exe
Did you define ES_JAVA_HOME by any chance?

Or did you define your own https certificates?
I'm wondering if anything could help in this documentation.

And in the code, I can see that you could specify the keystore location:

Not sure if this would help. Sorry, not an SSL expert here :frowning:

C:\Users\ashishkumar_shukla\Downloads\elasticsearch-8.8.2\bin>elasticsearch-sql-cli https://localhost:9200 -d
warning: ignoring JAVA_HOME=C:\Project IBM\openlogic-openjdk-8u272-b10-windows-64; using bundled JDK
Client Exception [Cannot POST address https://localhost:9200/?error_trace (PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target)]
org.elasticsearch.xpack.sql.client.ClientException: Cannot POST address https://localhost:9200/?error_trace (PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target)
at org.elasticsearch.xpack.sql.client.JreHttpUrlConnection.request(JreHttpUrlConnection.java:186)
at org.elasticsearch.xpack.sql.client.JreHttpUrlConnection.request(JreHttpUrlConnection.java:160)
at org.elasticsearch.xpack.sql.client.HttpClient.lambda$get$4(HttpClient.java:202)
at org.elasticsearch.xpack.sql.client.JreHttpUrlConnection.http(JreHttpUrlConnection.java:82)
at org.elasticsearch.xpack.sql.client.HttpClient.lambda$get$5(HttpClient.java:198)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:319)
at org.elasticsearch.xpack.sql.client.HttpClient.get(HttpClient.java:197)
at org.elasticsearch.xpack.sql.client.HttpClient.serverInfo(HttpClient.java:80)
at org.elasticsearch.xpack.sql.cli.command.CliSession.checkConnection(CliSession.java:40)
at org.elasticsearch.xpack.sql.cli.Cli.checkConnection(Cli.java:156)
at org.elasticsearch.xpack.sql.cli.Cli.execute(Cli.java:146)
at org.elasticsearch.xpack.sql.cli.Cli.execute(Cli.java:126)
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:85)
at org.elasticsearch.cli.Command.main(Command.java:50)
at org.elasticsearch.xpack.sql.cli.Cli.main(Cli.java:68)
Caused by: javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:130)
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:378)
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:321)
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:316)
at java.base/sun.security.ssl.CertificateMessage$T13CertificateConsumer.checkServerCerts(CertificateMessage.java:1318)
at java.base/sun.security.ssl.CertificateMessage$T13CertificateConsumer.onConsumeCertificate(CertificateMessage.java:1195)
at java.base/sun.security.ssl.CertificateMessage$T13CertificateConsumer.consume(CertificateMessage.java:1138)
at java.base/sun.security.ssl.SSLHandshake.consume(SSLHandshake.java:393)
at java.base/sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:469)
at java.base/sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:447)
at java.base/sun.security.ssl.TransportContext.dispatch(TransportContext.java:201)
at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:172)
at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1506)
at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1421)
at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:455)
at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:426)
at java.base/sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:587)
at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:187)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1657)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1581)
at java.base/java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:529)
at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:308)
at org.elasticsearch.xpack.sql.client.JreHttpUrlConnection.request(JreHttpUrlConnection.java:179)
... 14 more
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at java.base/sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:388)
at java.base/sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:271)
at java.base/sun.security.validator.Validator.validate(Validator.java:256)
at java.base/sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:230)
at java.base/sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:132)
at java.base/sun.security.ssl.CertificateMessage$T13CertificateConsumer.checkServerCerts(CertificateMessage.java:1302)
... 32 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at java.base/sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:146)
at java.base/sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:127)
at java.base/java.security.cert.CertPathBuilder.build(CertPathBuilder.java:297)
at java.base/sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:383)
... 37 more

ERROR: Cannot communicate with the server https://localhost:9200. This version of CLI only works with Elasticsearch version 8.8.2

C:\Users\ashishkumar_shukla\Downloads\elasticsearch-8.8.2\bin>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.