Connect to ElasticSearch Cloud 5.x with Java Client and X-Pack / HTTPS

Can I connect to ElasticSearch via HTTPS using the X-Pack? Using the switch to use the certificate, the native connection method no longer works. I have no problem using the certificate, but I need to know where to get it or load the key into the cloud instance, but I can not find the information anywhere. I also get no response from anyone on the forum or on the IRC.

Has anyone done this successfully? A warning when starting the 5.x instance no longer occurs, so I assumed it was possible, but I just can’t figure out how to do this. I was also told that I can no longer run the instance of 2.4.1, and only 2.4.2 is available (too unstable so far), so I don’t think about starting a useful instance.


Update

I was told that a certificate is not required because a public CA is being used. However, I still cannot figure out how to connect to the 5.1.1 instance.

Settings settings = Settings.builder()
            .put("transport.ping_schedule", "5s")
            .put("cluster.name", "<cluster_id>")
            .put("xpack.security.transport.ssl.enabled", "true")
            .put("xpack.security.user", "elastic:<password_from_cluster_creation>")
            .build();

    String hostname = "<cluster_id>.us-east-1.aws.found.io";
    TransportClient client = new PreBuiltXPackTransportClient(settings)
        .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(hostname), 9343));

What am I doing wrong here? I get an error node is not available.

Exception in thread "main" NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{xlhZqKBCQniYrN4OWzByFQ}{<cluster_id>.us-east-1.aws.found.io}{<id_address>:9343}]]

I also tried to create a user with the transport_client role, but still the same error.


Update 2

I tried the sample code and it still does not work.

https://github.com/elastic/found-shield-example/blob/master/src/main/java/org/elasticsearch/cloud/transport/example/TransportExample.java

. , .


3

. .

+4
1

ES - . , :

1) , ,

.put("request.headers.X-Found-Cluster", clusterName)

2) , , ,

https://github.com/elastic/found-shield-example#running

3) Eclipse, ${cluster.name} .

, , . ES 5.x , 2.x. , , .

+3

Source: https://habr.com/ru/post/1662883/


All Articles