In my Laravel 9 project, I use the Guzzle HTTP client to send requests like this:
private function getFromElasticsearch($request_uri, $data = NULL, $delegated_function = NULL) {
$result = Http::withOptions([
'debug' => true,
'crt' => '/home/XYZ/Documents/projets/elasticsearch_tests/http_ca.crt',
])->withBasicAuth(config('elasticsearch.authentication.client_id'), config('elasticsearch.authentication.secret'))->post(config('elasticsearch.connections.rest_api.endpoint') . '/customer/_search')->throw();
var_dump($result);
}
However, the .crt file doesn’t seem to be given to Elasticsearch, the service I try to call with Guzzle:
GuzzleHttpExceptionRequestException: cURL error 60: SSL certificate problem: self-signed certificate in certificate chain (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://172.18.0.9:9200/customer/_search in file /var/www/html/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php on line 211
When I use Postman to query Elasticsearch (giving it the CRT file), it works well. So I guess the problem comes from the use I make of GuzzleHttp. Maybe I don’t give the .crt file in the right way.
How could I pass the .crt file without having to use verify=>FALSE please? (indeed I’ve seen this solution in several sites, but I think it’s not the good one)