I can't connect to elasticsearch with SSL through PHP

I´m trying to connect to ES but it's been impossible.

that's my code in PHP

		$hosts = ['https://www.xxxxxxxx.com:6767'];			
		$myCert = 'xxxxxxxxxxxxxx/cert.pem';

		$client = ClientBuilder::create() // Instantiate a new ClientBuilder
		->setHosts($hosts)
		->setSSLVerification($myCert)
		->build(); // Build the client object

always the answer is NoNodesAvailableException

No alive nodes found in your cluster
StaticNoPingConnectionPool.php line 51

I hope that you can help me pls.

I got it! my problem was that I already have installed x-pack plugin in my elasticsearch instance, so the ssl certificates are already inside of elasticsearch.yml file. so the only code that i needed in PHP was:

            $hosts = ['https://www.xxxxxxxx.com:6767'];			

	$client = ClientBuilder::create() // Instantiate a new ClientBuilder
	->setHosts($hosts)
	->build(); // Build the client object

now it's working

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.