-
Notifications
You must be signed in to change notification settings - Fork 101
how to connect es with elasticsearch-php-sdk #22
Comments
Hi @y80x86ol, did you add the |
I add the cacert pem in my code, but still can't connection es. |
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 |
@aetter thank you for your reply! I disabling SSL verification,it works! code like this:
there are some same issues in other github: |
Hi @y80x86ol, gotcha, I'm going to close this one out. Thanks! |
I install open distro for elasticsearch,and open ssl, like "https://127.0.0.1:9200", use default admin account.
but when i use elasticsearch-php-sdk to connect es,it tell me "SSL Problem Received fatal alert: unknown_ca". Am I wrong?
but I can access it by browser.
https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/_security.html
thanks!
The text was updated successfully, but these errors were encountered: