You are here: Re: problems using cURL to access https « PHP Programming Language « IT news, forums, messages
Re: problems using cURL to access https

Posted by Chuck Anderson on 01/09/06 20:37

Rory wrote:

>I'm just starting to use cURL and having trouble accessing https pages.
> All I want to do at this stage is get an https page and display it,
>just to test the https get is working. However, I always get either a
>CURLE_OPERATION_TIMEOUTED (28) or CURLE_COULDNT_CONNECT (7) error.
>I can see from phpinfo() that cURL and SSL are installed, as follows:
> CURL support enabled
> CURL Information libcurl/7.12.0 OpenSSL/0.9.6b zlib/1.1.4
>but my code that works fine for an http call doesn't work for an https
>call. Any suggestions on what I might be doing wrong or what might be
>stopping the call from working? I'm on a hosted site so I don't have
>command line access.
>PHP Version 4.3.10, running on linux & apache.
>
>here's the code I'm running:
><?php
>$ch = curl_init();
>curl_setopt($ch, CURLOPT_URL, "https://myserviceall.com/index.php");
>// any old https page
>curl_setopt($ch, CURLOPT_TIMEOUT,10);
>$result = curl_exec ($ch);
>if (curl_error($ch)){
> print "<br>error #" . curl_errno($ch) . ": " . curl_error($ch);
>}
>curl_close ($ch);
>print $result;
>
>print "<br>end<br>";
>
>phpinfo();
>?>
>
>Same code works fine for an http url.
>
>I've also tried calling curl_setopt( $ch, CURLOPT_SSLVERSION, 2); since
>there was mention somewhere that might help, but same problem occurs.
>
>help greatly appreciated.
>
>- Rory
>
>
>
Try adding this option:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);

A tutorial that I found said it was necessary (and it worked for me).

--
*****************************
Chuck Anderson • Boulder, CO
http://www.CycleTourist.com
Integrity is obvious.
The lack of it is common.
*****************************

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация