Giter Club home page Giter Club logo

Comments (5)

aetter avatar aetter commented on July 26, 2024

Hi @y80x86ol, did you add the $myCert = 'path/to/cacert.pem'; line on that page for self-signed certificates? The default demo certificate that Open Distro for Elasticsearch uses is self-signed.

from for-elasticsearch-docs.

y80x86ol avatar y80x86ol commented on July 26, 2024

Hi @y80x86ol, did you add the $myCert = 'path/to/cacert.pem'; line on that page for self-signed certificates? The default demo certificate that Open Distro for Elasticsearch uses is self-signed.

I add the cacert pem in my code, but still can't connection es.
ps: i used the Open Distro for Elasticsearch demo certificate

from for-elasticsearch-docs.

aetter avatar aetter commented on July 26, 2024

Hi @y80x86ol, I was able to get this working after some struggles. Can you try the following?

<?php

require 'vendor/autoload.php';

use Elasticsearch\ClientBuilder;

$hosts = ['https://admin:admin@localhost:9200'];
$myCert = '/full/path/to/root-ca.pem';

$client = ClientBuilder::create()
                    ->setHosts($hosts)
                    ->setSSLVerification($myCert)
                    ->build();

$params = [
    'index' => 'test-index',
    'type' => '_doc',
    'id' => '1',
    'body' => ['testField' => 'abc']
];

$response = $client->index($params);
print_r($response);

?>

Then at the command line:

$ php -n -S 0.0.0.0:8000 index.php

And navigate to 0.0.0.0:8000 in your browser. Let me know. Thanks!

from for-elasticsearch-docs.

y80x86ol avatar y80x86ol commented on July 26, 2024

@aetter thank you for your reply!
I tried you code ,but still echo 'No alive nodes found in your cluster'.

I disabling SSL verification,it works!

code like this:

$hosts = ['https://admin:[email protected]:9210'];

$client = ClientBuilder::create()
    ->setHosts($hosts)
    ->setSSLVerification(false)
    ->build();

there are some same issues in other github:
elastic/elasticsearch-php#854
elastic/elasticsearch-php#850

from for-elasticsearch-docs.

aetter avatar aetter commented on July 26, 2024

Hi @y80x86ol, gotcha, I'm going to close this one out. Thanks!

from for-elasticsearch-docs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.