elasticsearch-php: SSL cert error

I am receiving the following error when trying to use the DELETE API.

Elasticsearch\\Common\\Exceptions\\TransportException","message":"SSL certificate problem: self signed certificate in certificate chain","file":"\pathto\/vendor\/elasticsearch\/elasticsearch\/src\/Elasticsearch\/Connections\/AbstractConnection.php","line":312

in my config file I am setting the verification to false. this is working for everything except delete.

update: I have done some research and it seems that the curl_opt - CURLOPT_SSL_VERIFYPEER is not getting set to false, is there a way to pass this using a config file to the elastic search client?

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 20 (7 by maintainers)

Most upvoted comments

@polyfractal I am using laravel, and came up with the same error as this thread, how to disable it when building the connection like so:

$client = ClientBuilder::create()
            ->setHosts([config('elastic.host')])
            ->setSSLVerification(false)
            ->setBasicAuthentication(config('elastic.user'), config('elastic.password'))
            ->build();         

Disabling SSL verification is always a bad idea. You might as well use http, since the https is useless then.

Well, I don’t have an opinion about if this is a good idea or not, but it seems Guzzle will allow you to set any curlopt that you want by prefacing it with curl.. You can access that via the guzzleOptions param:

$params = array();
$params['guzzleOptions'] = array(
    'curl.CURLOPT_SSL_VERIFYPEER' => false
);

$params['hosts'] = array ($_SERVER['ES_TEST_HOST']);
$client = new Elasticsearch\Client($params);
...

CURLOPT_SSL_VERIFYPEER is not getting set to false

This is how you solve a problem? By ignoring it? Not cool.

If your server is stupid and doesn’t have newest certificates, or you have self signed (which is equally stupid) than you should have used a certificate bundle or used a proper certificate (not self signed!).

https://github.com/Kdyby/CurlCaBundle