CURL: Result on console and in PHP are different

CURL: Result on console and in PHP are different

am 31.10.2007 11:10:30 von Paul van Brouwershaven

I have some problems with the curl. On the console I get the right
response message but in PHP I see no difference between a valid and an
invalid SSL Certificate.

Curl command in PHP:

$url = ' https://verisign.com';

$ch = curl_init();
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLE_OPERATION_TIMEOUTED, 10);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
$result = curl_exec ($ch);
$info = curl_getinfo($ch);
curl_close ($ch);

print_r($info);

Curl command on console:

curl -I https://verisign.com

Wrong SSL Certificate:

curl -I https://verisign.com
curl: (51) SSL: certificate subject name 'www.verisign.com' does not
match target host name 'verisign.com'

Array
(
[url] => https://verisign.com
[http_code] => 0
[header_size] => 0
[request_size] => 0
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0
[namelookup_time] => 0
[connect_time] => 0
[pretransfer_time] => 0
[size_upload] => 0
[size_download] => 0
[speed_download] => 0
[speed_upload] => 0
[download_content_length] => 0
[upload_content_length] => 0
[starttransfer_time] => 0
[redirect_time] => 0
)

Correct SSL Certificate:

curl -I https://www.verisign.com
HTTP/1.1 200 OK
Server: Netscape-Enterprise/4.1
Date: Wed, 31 Oct 2007 09:56:59 GMT
Set-Cookie: v1st=4728516C0AACA713; path=/; expires=Wed, 19 Feb 2020
14:28:00 GMT; domain=.verisign.com
Content-type: text/html


Array
(
[url] => https://www.verisign.com
[http_code] => 0
[header_size] => 0
[request_size] => 0
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0
[namelookup_time] => 0
[connect_time] => 0
[pretransfer_time] => 0
[size_upload] => 0
[size_download] => 0
[speed_download] => 0
[speed_upload] => 0
[download_content_length] => 0
[upload_content_length] => 0
[starttransfer_time] => 0
[redirect_time] => 0
)

Re: CURL: Result on console and in PHP are different

am 31.10.2007 11:21:34 von Jerry Stuckle

Paul van Brouwershaven wrote:
> I have some problems with the curl. On the console I get the right
> response message but in PHP I see no difference between a valid and an
> invalid SSL Certificate.
>



Yes, the certificate is set up for www.verisign.com, so when you try to
go to verisign.com you get a name mismatch and it fails.

FYI, Firefox shows a message indicating the mismatch when you try to
https://verisign.com, also.


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: CURL: Result on console and in PHP are different

am 31.10.2007 11:30:37 von Paul van Brouwershaven

On Oct 31, 11:21 am, Jerry Stuckle wrote:
> Yes, the certificate is set up forwww.verisign.com, so when you try to
> go to verisign.com you get a name mismatch and it fails.
>
> FYI, Firefox shows a message indicating the mismatch when you try to https://verisign.com, also.
Yes I know, thats the reason I try https://verisign.com but PHP is not
giving me the error message/number in the [ssl_verify_result] value.

I also tried:

$url = ' https://www.verisign.com';

$ch = curl_init();
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLE_OPERATION_TIMEOUTED, 10);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_CAINFO, '/usr/share/curl/cacert.pem');
curl_setopt($ch, CURLOPT_CAPATH, '/usr/share/curl/cacert.pem');
curl_setopt($ch, CURL_CA_BUNDLE, '/usr/share/curl/cacert.pem');

$result = curl_exec ($ch);
$info = curl_getinfo($ch);
curl_close ($ch);

print_r($info);

Re: CURL: Result on console and in PHP are different

am 31.10.2007 11:58:16 von Jerry Stuckle

Paul van Brouwershaven wrote:
> On Oct 31, 11:21 am, Jerry Stuckle wrote:
>> Yes, the certificate is set up forwww.verisign.com, so when you try to
>> go to verisign.com you get a name mismatch and it fails.
>>
>> FYI, Firefox shows a message indicating the mismatch when you try to https://verisign.com, also.
> Yes I know, thats the reason I try https://verisign.com but PHP is not
> giving me the error message/number in the [ssl_verify_result] value.
>
> I also tried:
>
> $url = ' https://www.verisign.com';
>
> $ch = curl_init();
> curl_setopt($ch, CURLOPT_TIMEOUT, 10);
> curl_setopt($ch, CURLE_OPERATION_TIMEOUTED, 10);
> curl_setopt($ch, CURLOPT_URL, $url);
> curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
> curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
> curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
> curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
> curl_setopt($ch, CURLOPT_CAINFO, '/usr/share/curl/cacert.pem');
> curl_setopt($ch, CURLOPT_CAPATH, '/usr/share/curl/cacert.pem');
> curl_setopt($ch, CURL_CA_BUNDLE, '/usr/share/curl/cacert.pem');
>
> $result = curl_exec ($ch);
> $info = curl_getinfo($ch);
> curl_close ($ch);
>
> print_r($info);
>
>

Sorry, I misunderstood your question.

What do you get for the results from curl_init()?



--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: CURL: Result on console and in PHP are different

am 31.10.2007 12:07:24 von Jerry Stuckle

Paul van Brouwershaven wrote:
> On Oct 31, 11:21 am, Jerry Stuckle wrote:
>> Yes, the certificate is set up forwww.verisign.com, so when you try to
>> go to verisign.com you get a name mismatch and it fails.
>>
>> FYI, Firefox shows a message indicating the mismatch when you try to https://verisign.com, also.
> Yes I know, thats the reason I try https://verisign.com but PHP is not
> giving me the error message/number in the [ssl_verify_result] value.
>
> I also tried:
>
> $url = ' https://www.verisign.com';
>
> $ch = curl_init();
> curl_setopt($ch, CURLOPT_TIMEOUT, 10);
> curl_setopt($ch, CURLE_OPERATION_TIMEOUTED, 10);
> curl_setopt($ch, CURLOPT_URL, $url);
> curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
> curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
> curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
> curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
> curl_setopt($ch, CURLOPT_CAINFO, '/usr/share/curl/cacert.pem');
> curl_setopt($ch, CURLOPT_CAPATH, '/usr/share/curl/cacert.pem');
> curl_setopt($ch, CURL_CA_BUNDLE, '/usr/share/curl/cacert.pem');
>
> $result = curl_exec ($ch);
> $info = curl_getinfo($ch);
> curl_close ($ch);
>
> print_r($info);
>
>

Also, IIRC, the results form the curl_init() should be false, and you
should be able to get the error info from curl_errno() and/or
curl_error(), not curl_getinfo().

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: CURL: Result on console and in PHP are different

am 31.10.2007 12:11:42 von Paul van Brouwershaven

On Oct 31, 11:58 am, Jerry Stuckle wrote:
> Sorry, I misunderstood your question.
No problem

> What do you get for the results from curl_init()?
"$result = curl_exec ($ch);" results noting
"$ch = curl_init();" results "Resource id #26"

Re: CURL: Result on console and in PHP are different

am 31.10.2007 12:18:23 von Jerry Stuckle

Jerry Stuckle wrote:
> Paul van Brouwershaven wrote:
>> On Oct 31, 11:21 am, Jerry Stuckle wrote:
>>> Yes, the certificate is set up forwww.verisign.com, so when you try to
>>> go to verisign.com you get a name mismatch and it fails.
>>>
>>> FYI, Firefox shows a message indicating the mismatch when you try to
>>> https://verisign.com, also.
>> Yes I know, thats the reason I try https://verisign.com but PHP is not
>> giving me the error message/number in the [ssl_verify_result] value.
>>
>> I also tried:
>>
>> $url = ' https://www.verisign.com';
>>
>> $ch = curl_init();
>> curl_setopt($ch, CURLOPT_TIMEOUT, 10);
>> curl_setopt($ch, CURLE_OPERATION_TIMEOUTED, 10);
>> curl_setopt($ch, CURLOPT_URL, $url);
>> curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
>> curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
>> curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
>> curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
>> curl_setopt($ch, CURLOPT_CAINFO, '/usr/share/curl/cacert.pem');
>> curl_setopt($ch, CURLOPT_CAPATH, '/usr/share/curl/cacert.pem');
>> curl_setopt($ch, CURL_CA_BUNDLE, '/usr/share/curl/cacert.pem');
>>
>> $result = curl_exec ($ch);
>> $info = curl_getinfo($ch);
>> curl_close ($ch);
>>
>> print_r($info);
>>
>>
>
> Also, IIRC, the results form the curl_init() should be false, and you
> should be able to get the error info from curl_errno() and/or
> curl_error(), not curl_getinfo().
>

Sorry, I mean the results from curl_exec() should be false.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: CURL: Result on console and in PHP are different

am 31.10.2007 12:19:15 von Jerry Stuckle

Paul van Brouwershaven wrote:
> On Oct 31, 11:58 am, Jerry Stuckle wrote:
>> Sorry, I misunderstood your question.
> No problem
>
>> What do you get for the results from curl_init()?
> "$result = curl_exec ($ch);" results noting
> "$ch = curl_init();" results "Resource id #26"
>
>

OK, so it initializes ok - but the execution fails. So the results
should be in curl_error() and curl_errno().

I should know not to answer these things before my first pot of coffee! :-)

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: CURL: Result on console and in PHP are different

am 31.10.2007 12:22:48 von luiheidsgoeroe

On Wed, 31 Oct 2007 11:30:37 +0100, Paul van Brouwershaven =

wrote:

> On Oct 31, 11:21 am, Jerry Stuckle wrote:
>> Yes, the certificate is set up forwww.verisign.com, so when you try t=
o
>> go to verisign.com you get a name mismatch and it fails.
>>
>> FYI, Firefox shows a message indicating the mismatch when you try to =
=

>> https://verisign.com, also.
> Yes I know, thats the reason I try https://verisign.com but PHP is not=

> giving me the error message/number in the [ssl_verify_result] value.
>
> I also tried:
>
> $url =3D ' https://www.verisign.com';
>
> $ch =3D curl_init();
> curl_setopt($ch, CURLOPT_TIMEOUT, 10);
> curl_setopt($ch, CURLE_OPERATION_TIMEOUTED, 10);
> curl_setopt($ch, CURLOPT_URL, $url);
> curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
> curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
> curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
> curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
> curl_setopt($ch, CURLOPT_CAINFO, '/usr/share/curl/cacert.pem');
> curl_setopt($ch, CURLOPT_CAPATH, '/usr/share/curl/cacert.pem');
> curl_setopt($ch, CURL_CA_BUNDLE, '/usr/share/curl/cacert.pem');
>
> $result =3D curl_exec ($ch);
> $info =3D curl_getinfo($ch);
> curl_close ($ch);
>
> print_r($info);


//notice it doesn't start with a space...
$url =3D 'https://www.verisign.com';

$ch =3D curl_init();
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLE_OPERATION_TIMEOUTED, 10);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
=

$result =3D curl_exec ($ch);
if(!$result) echo curl_error($ch);
$info =3D curl_getinfo($ch);
curl_close ($ch);

print_r($info);
?>



-- =

Rik Wasmus

Re: CURL: Result on console and in PHP are different

am 31.10.2007 12:31:29 von Paul van Brouwershaven

As saw the space problem just before you post, but this still doesn't
solve the problem that there is no value in the ssl_verify_result
result.

If the SSL Certificate is wrong or right it always returns 0!

I can check the result of the curl_exec to see if the certificate is
valid, but this doen't tell me what the problem is.

Re: CURL: Result on console and in PHP are different

am 31.10.2007 13:04:47 von luiheidsgoeroe

On Wed, 31 Oct 2007 12:31:29 +0100, Paul van Brouwershaven =

wrote:

> As saw the space problem just before you post, but this still doesn't
> solve the problem that there is no value in the ssl_verify_result
> result.
>
> If the SSL Certificate is wrong or right it always returns 0!
>
> I can check the result of the curl_exec to see if the certificate is
> valid, but this doen't tell me what the problem is.

Well, I get a clear:
"SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate veri=
fy =

failed"

...with curl_error(), as I don't have the certificate.

set verify peer to false would result in either this curl_error() output=
:
SSL: certificate subject name 'www.verisign.com' does not match target =

host name 'verisign.com'
[ssl_verify_result] =3D> 0]

Or no error with the right hostname:
[ssl_verify_result] =3D> 19]
-- =

Rik Wasmus

Re: CURL: Result on console and in PHP are different

am 31.10.2007 17:14:30 von Paul van Brouwershaven

On Oct 31, 1:04 pm, "Rik Wasmus" wrote:
> Well, I get a clear:
> "SSL certificate problem, verify that the CA cert is OK. Details:
> error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify
> failed"
>
> ..with curl_error(), as I don't have the certificate.
Ok found the problem, the curl_close($ch) was before the
curl_error($ch)

> set verify peer to false would result in either this curl_error() output:
> SSL: certificate subject name 'www.verisign.com'does not match target
> host name 'verisign.com'
> [ssl_verify_result] => 0]

> Or no error with the right hostname:
> [ssl_verify_result] => 19]

ssl_verify_result does not change in my results

Re: CURL: Result on console and in PHP are different

am 31.10.2007 17:36:28 von Good Man

Paul van Brouwershaven wrote in
news:1193847270.228502.306510@22g2000hsm.googlegroups.com:

> On Oct 31, 1:04 pm, "Rik Wasmus" wrote:
>> Well, I get a clear:
>> "SSL certificate problem, verify that the CA cert is OK. Details:
>> error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate
>> verify failed"
>>
>> ..with curl_error(), as I don't have the certificate.
> Ok found the problem, the curl_close($ch) was before the
> curl_error($ch)
>
>> set verify peer to false would result in either this curl_error()
>> output: SSL: certificate subject name 'www.verisign.com'does not
>> match target host name 'verisign.com'
>> [ssl_verify_result] => 0]
>
>> Or no error with the right hostname:
>> [ssl_verify_result] => 19]
>
> ssl_verify_result does not change in my results

are you still using "verisign.com" and not "www.verisign.com" ?

[PHISHING]: Re: CURL: Result on console and in PHP are different

am 31.10.2007 18:05:20 von Jerry Stuckle

------------------------------------------------------------ ---------------------------------------
Panda IS 2008 has detected that this email could be spoofed

Take maximum precautions, as spoofed emails could be the sign of a fraud attempt.
------------------------------------------------------------ ---------------------------------------
Paul van Brouwershaven wrote:
> On Oct 31, 1:04 pm, "Rik Wasmus" wrote:
>> Well, I get a clear:
>> "SSL certificate problem, verify that the CA cert is OK. Details:
>> error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify
>> failed"
>>
>> ..with curl_error(), as I don't have the certificate.
> Ok found the problem, the curl_close($ch) was before the
> curl_error($ch)
>
>> set verify peer to false would result in either this curl_error() output:
>> SSL: certificate subject name 'www.verisign.com'does not match target
>> host name 'verisign.com'
>> [ssl_verify_result] => 0]
>
>> Or no error with the right hostname:
>> [ssl_verify_result] => 19]
>
> ssl_verify_result does not change in my results
>
>

No, it won't. The request failed, so there is no info to get.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

------------------------------------------------------------ ---------------------------------------
Panda IS 2008 has detected that this email could be spoofed

Take maximum precautions, as spoofed emails could be the sign of a fraud attempt.
------------------------------------------------------------ ---------------------------------------

Re: [PHISHING]: Re: CURL: Result on console and in PHP are different

am 31.10.2007 18:17:55 von luiheidsgoeroe

On Wed, 31 Oct 2007 18:05:20 +0100, Jerry Stuckle
wrote:
> Panda IS 2008 has detected that this email could be spoofed

Hehehe :P
--
Rik Wasmus

[PHISHING]: Re: CURL: Result on console and in PHP are different

am 31.10.2007 19:52:24 von Jerry Stuckle

------------------------------------------------------------ ---------------------------------------
Panda IS 2008 has detected that this email could be spoofed

Take maximum precautions, as spoofed emails could be the sign of a fraud attempt.
------------------------------------------------------------ ---------------------------------------
Jerry Stuckle wrote:

> Paul van Brouwershaven wrote:
>> On Oct 31, 1:04 pm, "Rik Wasmus" wrote:
>>> Well, I get a clear:
>>> "SSL certificate problem, verify that the CA cert is OK. Details:
>>> error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate
>>> verify
>>> failed"
>>>
>>> ..with curl_error(), as I don't have the certificate.
>> Ok found the problem, the curl_close($ch) was before the
>> curl_error($ch)
>>
>>> set verify peer to false would result in either this curl_error()
>>> output:
>>> SSL: certificate subject name 'www.verisign.com'does not match target
>>> host name 'verisign.com'
>>> [ssl_verify_result] => 0]
>>
>>> Or no error with the right hostname:
>>> [ssl_verify_result] => 19]
>>
>> ssl_verify_result does not change in my results
>>
>>
>
> No, it won't. The request failed, so there is no info to get.
>

Sorry - forgot to trim the anti-virus. Wish I could get it to stop
doing that in newsgroups.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

------------------------------------------------------------ ---------------------------------------
Panda IS 2008 has detected that this email could be spoofed

Take maximum precautions, as spoofed emails could be the sign of a fraud attempt.
------------------------------------------------------------ ---------------------------------------

Re: [PHISHING]: Re: CURL: Result on console and in PHP are different

am 01.11.2007 06:35:17 von Jackie Silva

stuckle, why are you top posting? have you given up so quickly on your
position?

"Jerry Stuckle" wrote in message
news:apKdndHjGeZwKLXanZ2dnUVZ_hninZ2d@comcast.com...
>
> ------------------------------------------------------------ ---------------------------------------
> Panda IS 2008 has detected that this email could be spoofed
>
> Take maximum precautions, as spoofed emails could be the sign of a fraud
> attempt.
> ------------------------------------------------------------ ---------------------------------------
> Paul van Brouwershaven wrote:
>> On Oct 31, 1:04 pm, "Rik Wasmus" wrote:
>>> Well, I get a clear:
>>> "SSL certificate problem, verify that the CA cert is OK. Details:
>>> error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate
>>> verify
>>> failed"
>>>
>>> ..with curl_error(), as I don't have the certificate.
>> Ok found the problem, the curl_close($ch) was before the
>> curl_error($ch)
>>
>>> set verify peer to false would result in either this curl_error()
>>> output:
>>> SSL: certificate subject name 'www.verisign.com'does not match target
>>> host name 'verisign.com'
>>> [ssl_verify_result] => 0]
>>
>>> Or no error with the right hostname:
>>> [ssl_verify_result] => 19]
>>
>> ssl_verify_result does not change in my results
>>
>>
>
> No, it won't. The request failed, so there is no info to get.
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstucklex@attglobal.net
> ==================
>
> ------------------------------------------------------------ ---------------------------------------
> Panda IS 2008 has detected that this email could be spoofed
>
> Take maximum precautions, as spoofed emails could be the sign of a fraud
> attempt.
> ------------------------------------------------------------ ---------------------------------------
>

Re: : Re: CURL: Result on console and in PHP are different

am 01.11.2007 08:53:33 von Paul van Brouwershaven

Yes, there must be a failed status in the [ssl_verify_result]. Or a
success status in the [ssl_verify_result] but this value is always
zore.

A faild status should more logical because it can fail because of more
then one reason.