Bug->Doc #19351 [Fbk->Opn]: SSL certificate validation
| From: | borz_off at cs dot msu dot su | Date: | Mon, 26 Mar 2012 19:29:35 +0000 |
| Subject: | Bug->Doc #19351 [Fbk->Opn]: SSL certificate validation | ||
| References: | 1 | Groups: | php.pear.bugs |
| Request: | Send a blank email to pear-bugs+get-8455@lists.php.net to get a copy of this message | ||
Edit report at https://pear.php.net/bugs/bug.php?id=19351&edit=1
ID: 19351
Updated by: borz_off@cs.msu.su
Reported By: till at php dot net
-Summary: stream_socket_client
+Summary: SSL certificate validation
-Status: Feedback
+Status: Open
-Type: Bug
+Type: Documentation Problem
Package: HTTP_Request2
Package Version: 2.0.0
PHP Version: 5.3.8
Roadmap Versions:
New Comment:
-Summary: stream_socket_client
+Summary: SSL certificate validation
-Status: Feedback
+Status: Open
-Type: Bug
+Type: Documentation Problem
Well, locally (on Windows) both adapters do yield the same result as
both fail to validate server certificate. :]
If I download cacert.pem from http://curl.haxx.se/docs/caextract.html
and pass it as ssl_cafile, both of them succeed.
If you learn something useful about defaults, I'll gladly put that into
the docs.
Previous Comments:
------------------------------------------------------------------------
[2012-03-26 19:26:22] till
From Googling it seems like I'm not the first to run into this (and open
a bug ;)). The
error in regard to 'socket' is in verifying the SSL cert. But I'm not
sure why the
defaults in cURL work and in socket they do not.
You previously suggest on another issue to set the ssl_capath- and
ssl_cafile-options.
I'm still trying to figure out what these default with cURL too, but I
can't figure out
where these are kept.
When I $req->setAdapter('curl') - it works instantly.
Shouldn't both adapters yield the same result?
------------------------------------------------------------------------
[2012-03-26 19:23:43] avb
I see creation of $ctx in your code, but I don't see it being used in
stream_socket_client() call.
------------------------------------------------------------------------
[2012-03-26 19:14:56] till
OK, trunk is very verbose! I like that!
I checked out HTTP_Request2-trunk into my vendor dir and prepended it to
the
include_path.
This is the output:
Fatal error: Uncaught HTTP_Request2_ConnectionException: Unable to
connect to
ssl://metrics-api.librato.com:443. Error: stream_socket_client(): unable
to connect to
ssl://metrics-api.librato.com:443 (Unknown error)
stream_socket_client(): Failed to enable crypto
stream_socket_client(): SSL operation failed with code 1. OpenSSL Error
messages:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate
verify
failed in /path/vendor/HTTP_Request2/HTTP/Request2/Adapter/Socket.php on
line
163
#0 /path/vendor/HTTP_Request2/HTTP/Request2/Adapter/Socket.php(163):
HTTP_Request2_Adapter_Socket->connect()
#1 /path/vendor/HTTP_Request2/HTTP/Request2.php(943):
HTTP_Request2_Adapter_Socket->sendRequest(Object(HTTP_Request2))
#2 /path/test.php(27): HTTP_Request2->send()
#3 {main}
thrown in /path/vendor/HTTP_Request2/HTTP/Request2/Adapter/Socket.php
on line
337
Any idea which opens cause this to fail from within HTTP_Request2 when
my simple
stream_socket_client() which verifies as well doesn't error?
------------------------------------------------------------------------
[2012-03-26 18:59:58] till
I'll check out trunk in the meantime.
------------------------------------------------------------------------
[2012-03-26 18:59:19] till
I think my previous comment made no sense since the wrapper is 'ssl://'
not
'https://', my mistake, but I'm still debugging the
issue:
My remote is: https://metrics-api.librato.com/
In HTTP_Request2, this is turned into this:
'ssl://metrics-api.librato.com:443'. I came
up with this test script:
<?php
$ctx = stream_context_create(array(
'http' => array(
'ignore_errors' => true,
),
'ssl' => array(
'CN_match' => "metrics-api.librato.com",
'verify_peer' => true,
),
));
$remote = 'ssl://metrics-api.librato.com:443';
ini_set('track_errors', 1);
$socket = stream_socket_client($remote, $errno, $errstr, 2);
var_dump($socket);
var_dump($errno, $errstr);
if (isset($php_errormsg)) {
var_dump($php_errormsg);
}
This seems to set the same SSL-options HTTP_Request2 sets, but with
HTTP_Request2 I get an "unknown error" which I cannot reproduce with
this script.
Do you have any idea how I could debug this further?
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://pear.php.net/bugs/bug.php?id=19351
--
Edit this bug report at https://pear.php.net/bugs/bug.php?id=19351&edit=1