elastic / elasticsearch

Free and Open Source, Distributed, RESTful Search Engine
https://www.elastic.co/products/elasticsearch
Other
69.61k stars 24.63k forks source link

Simplify JDBC URL and improve Error Messages #97351

Closed wise-coders closed 1 year ago

wise-coders commented 1 year ago

Description

Please make the JDBC URL connectivity more simple. Like the URL to contain the host, port. I tried connecting using

jdbc:es://https://localhost:9200

and received in server logs

Received plaintext http traffic on an https channel, closing connection

and in the driver

java.sql.SQLException: shadow.org.elasticsearch.xpack.sql.client.ClientException: Cannot POST address http://localhost:9200/?error_trace (Unexpected end of file from server)

I changed to :

jdbc:es://https://localhost:9200

and I still get in the server:

http client did not trust this server's certificate

and in the driver:

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)

How can I fix this?

The error in the JDBC Call should be very suggestive, stating clear what I have to do. The driver should try by himself to use https: or http:, and also find a way to trust this certificates. Compare with MySql, which is also encrypting the communication. But the connectivity works without additional steps.

elasticsearchmachine commented 1 year ago

Pinging @elastic/es-ql (Team:QL)

bpintea commented 1 year ago

@wise-coders, thanks for your interest in using JDBC and Elasticsearch. Please use https://discuss.elastic.co/ for getting help on using the two. I'm going to close this issue, but please feel free to open a new one if there's a feature the products could be improved with, or if you encounter a bug.

To the problem you're asking for help about: I'm assuming you've configured your Elasticsearch instance to handle SSL traffic on port 9200 using self-signed certificates. You might want to have a look at the available SSL config JDBC options that there are.