Php api and self signed certs

Hi,

I am trying to get the configuration example from here to work:

http://www.elasticsearch.org/guide/en/elasticsearch/client/php-api/current/_security.html#_guzzleconnection_self_signed_certificate

My settings look like this:

19 // Elasticsearch
20 $clientparams = array();
21 $clientparams['hosts'] = array(
22 'https://host01:443'
23 );
24
25 $clientparams['guzzleOptions'] = array(
26 '\Guzzle\Http\Client::SSL_CERT_AUTHORITY' => 'system',
27 '\Guzzle\Http\Client::CURL_OPTIONS' => [
28 'CURLOPT_SSL_VERIFYPEER' => true,
29 'CURLOPT_SSL_VERIFYHOST' => 2,
30 'CURLOPT_CAINFO' => '.inc/cacert.pem',
31 'CURLOPT_SSLCERTTYPE' => 'PEM',
32 ]
33 );

The error:

PHP Fatal error: Uncaught exception
'Elasticsearch\Common\Exceptions\TransportException' with message 'SSL
certificate problem: self signed certificate'

What did I miss?

Thanks!

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/85316e18-cc6b-49b1-8f72-6d0476cfd166%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Well, I got it working but had to make the declarations in CurlHandle.php

I added:

$curlOptions[CURLOPT_SSL_VERIFYPEER] = true;
$curlOptions[CURLOPT_CAINFO] = '/full/path/to/cacert.pem';

directly above:

curl_setopt_array($handle, $curlOptions);
return new static($handle, $curlOptions);
...

What's strange is that I also tried placing them in the default
$curlOptions but those seemed to get dumped somewhere prior to
curl_setopt_array()

Yucky, but working.

On Monday, February 9, 2015 at 7:05:34 PM UTC-4, Paul Halliday wrote:

Hi,

I am trying to get the configuration example from here to work:

Elasticsearch Platform — Find real-time answers at scale | Elastic

My settings look like this:

19 // Elasticsearch
20 $clientparams = array();
21 $clientparams['hosts'] = array(
22 'https://host01:443'
23 );
24
25 $clientparams['guzzleOptions'] = array(
26 '\Guzzle\Http\Client::SSL_CERT_AUTHORITY' => 'system',
27 '\Guzzle\Http\Client::CURL_OPTIONS' => [
28 'CURLOPT_SSL_VERIFYPEER' => true,
29 'CURLOPT_SSL_VERIFYHOST' => 2,
30 'CURLOPT_CAINFO' => '.inc/cacert.pem',
31 'CURLOPT_SSLCERTTYPE' => 'PEM',
32 ]
33 );

The error:

PHP Fatal error: Uncaught exception
'Elasticsearch\Common\Exceptions\TransportException' with message 'SSL
certificate problem: self signed certificate'

What did I miss?

Thanks!

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/4dfff5aa-8040-44d5-af8e-5c2380c4ac55%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

I suspect that it is because you put your constant names in quotes, and as
a result the keys are going to be wrong. i.e. you
have 'CURLOPT_SSL_VERIFYPEER' => true, while it should probably be
CURLOPT_SSL_VERIFYPEER => true as shown in the link you provided.

Ian

On Tuesday, February 10, 2015 at 10:42:05 AM UTC-5, Paul Halliday wrote:

Well, I got it working but had to make the declarations in CurlHandle.php

I added:

$curlOptions[CURLOPT_SSL_VERIFYPEER] = true;
$curlOptions[CURLOPT_CAINFO] = '/full/path/to/cacert.pem';

directly above:

curl_setopt_array($handle, $curlOptions);
return new static($handle, $curlOptions);
...

What's strange is that I also tried placing them in the default
$curlOptions but those seemed to get dumped somewhere prior to
curl_setopt_array()

Yucky, but working.

On Monday, February 9, 2015 at 7:05:34 PM UTC-4, Paul Halliday wrote:

Hi,

I am trying to get the configuration example from here to work:

Elasticsearch Platform — Find real-time answers at scale | Elastic

My settings look like this:

19 // Elasticsearch
20 $clientparams = array();
21 $clientparams['hosts'] = array(
22 'https://host01:443'
23 );
24
25 $clientparams['guzzleOptions'] = array(
26 '\Guzzle\Http\Client::SSL_CERT_AUTHORITY' => 'system',
27 '\Guzzle\Http\Client::CURL_OPTIONS' => [
28 'CURLOPT_SSL_VERIFYPEER' => true,
29 'CURLOPT_SSL_VERIFYHOST' => 2,
30 'CURLOPT_CAINFO' => '.inc/cacert.pem',
31 'CURLOPT_SSLCERTTYPE' => 'PEM',
32 ]
33 );

The error:

PHP Fatal error: Uncaught exception
'Elasticsearch\Common\Exceptions\TransportException' with message 'SSL
certificate problem: self signed certificate'

What did I miss?

Thanks!

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/8df0c2ba-daa8-4a77-b1e8-60f00ed28ed7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

That is the hint I needed.

I had it w/o quotes at first and the page was failing. I just assumed this
was because of the lack of quotes, which once added allowed the page to
load. I should have looked at the error console, which was showing the
missing include :slight_smile:

All is good and working as expected.

On Tuesday, February 10, 2015 at 11:17:20 PM UTC-4, Ian MacLennan wrote:

I suspect that it is because you put your constant names in quotes, and as
a result the keys are going to be wrong. i.e. you
have 'CURLOPT_SSL_VERIFYPEER' => true, while it should probably be
CURLOPT_SSL_VERIFYPEER => true as shown in the link you provided.

Ian

On Tuesday, February 10, 2015 at 10:42:05 AM UTC-5, Paul Halliday wrote:

Well, I got it working but had to make the declarations in CurlHandle.php

I added:

$curlOptions[CURLOPT_SSL_VERIFYPEER] = true;
$curlOptions[CURLOPT_CAINFO] = '/full/path/to/cacert.pem';

directly above:

curl_setopt_array($handle, $curlOptions);
return new static($handle, $curlOptions);
...

What's strange is that I also tried placing them in the default
$curlOptions but those seemed to get dumped somewhere prior to
curl_setopt_array()

Yucky, but working.

On Monday, February 9, 2015 at 7:05:34 PM UTC-4, Paul Halliday wrote:

Hi,

I am trying to get the configuration example from here to work:

Elasticsearch Platform — Find real-time answers at scale | Elastic

My settings look like this:

19 // Elasticsearch
20 $clientparams = array();
21 $clientparams['hosts'] = array(
22 'https://host01:443'
23 );
24
25 $clientparams['guzzleOptions'] = array(
26 '\Guzzle\Http\Client::SSL_CERT_AUTHORITY' => 'system',
27 '\Guzzle\Http\Client::CURL_OPTIONS' => [
28 'CURLOPT_SSL_VERIFYPEER' => true,
29 'CURLOPT_SSL_VERIFYHOST' => 2,
30 'CURLOPT_CAINFO' => '.inc/cacert.pem',
31 'CURLOPT_SSLCERTTYPE' => 'PEM',
32 ]
33 );

The error:

PHP Fatal error: Uncaught exception
'Elasticsearch\Common\Exceptions\TransportException' with message 'SSL
certificate problem: self signed certificate'

What did I miss?

Thanks!

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/a83720d1-5840-48c3-a952-ea6c38619ba5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Glad you got it working! Just a note, I don't monitor the ES mailing list
very closely...but if you have any more problems/questions with the PHP
client in the future, feel free to just open a tick at the repo and I would
be happy to help :slight_smile:

-Z

On Wednesday, February 11, 2015 at 7:09:57 AM UTC-5, Paul Halliday wrote:

That is the hint I needed.

I had it w/o quotes at first and the page was failing. I just assumed this
was because of the lack of quotes, which once added allowed the page to
load. I should have looked at the error console, which was showing the
missing include :slight_smile:

All is good and working as expected.

On Tuesday, February 10, 2015 at 11:17:20 PM UTC-4, Ian MacLennan wrote:

I suspect that it is because you put your constant names in quotes, and
as a result the keys are going to be wrong. i.e. you
have 'CURLOPT_SSL_VERIFYPEER' => true, while it should probably be
CURLOPT_SSL_VERIFYPEER => true as shown in the link you provided.

Ian

On Tuesday, February 10, 2015 at 10:42:05 AM UTC-5, Paul Halliday wrote:

Well, I got it working but had to make the declarations in CurlHandle.php

I added:

$curlOptions[CURLOPT_SSL_VERIFYPEER] = true;
$curlOptions[CURLOPT_CAINFO] = '/full/path/to/cacert.pem';

directly above:

curl_setopt_array($handle, $curlOptions);
return new static($handle, $curlOptions);
...

What's strange is that I also tried placing them in the default
$curlOptions but those seemed to get dumped somewhere prior to
curl_setopt_array()

Yucky, but working.

On Monday, February 9, 2015 at 7:05:34 PM UTC-4, Paul Halliday wrote:

Hi,

I am trying to get the configuration example from here to work:

Elasticsearch Platform — Find real-time answers at scale | Elastic

My settings look like this:

19 // Elasticsearch
20 $clientparams = array();
21 $clientparams['hosts'] = array(
22 'https://host01:443'
23 );
24
25 $clientparams['guzzleOptions'] = array(
26 '\Guzzle\Http\Client::SSL_CERT_AUTHORITY' => 'system',
27 '\Guzzle\Http\Client::CURL_OPTIONS' => [
28 'CURLOPT_SSL_VERIFYPEER' => true,
29 'CURLOPT_SSL_VERIFYHOST' => 2,
30 'CURLOPT_CAINFO' => '.inc/cacert.pem',
31 'CURLOPT_SSLCERTTYPE' => 'PEM',
32 ]
33 );

The error:

PHP Fatal error: Uncaught exception
'Elasticsearch\Common\Exceptions\TransportException' with message 'SSL
certificate problem: self signed certificate'

What did I miss?

Thanks!

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/4821d7fc-5ce0-4b1a-a46f-fb20c61eb475%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.