note 44349 deleted from function.curl-setopt by daverandom
| From: | daverandom@php.net | Date: | Mon, 13 Jan 2014 10:43:17 +0000 |
| Subject: | note 44349 deleted from function.curl-setopt by daverandom | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-198222@lists.php.net to get a copy of this message | ||
Note Submitter: raul at navenetworks dot com
----
Hi!
I have found some information I am sure it could help lot of programmers when they want to connect
with curl to any https website and they haven't a good or right CA Cert :)
I give you just one example It has resolved me 2 hours of my time looking for a solution.
It is simple, just if you get any error in the curl_exec (use curl_error(...) to see the error to
trace it) add the next line and everything is solved:
(note: replace $ch with the right curl variable)
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
<?php
$ch = curl_init();
$res= curl_setopt ($ch, CURLOPT_URL,"https://yoururl/cgi");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "Idc=si&");
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$xyz = curl_exec ($ch);
curl_close ($ch);
echo $xyz;
if ($xyz == NULL) {
echo "Error:<br>";
echo curl_errno($ch) . " - " . curl_error($ch) . "<br>";
}
?>
I hope this helps.
Raul Mate Galan
Ceo Navenetworks Corp.
Note: Thanks to Ruben Lopez Gea for his help too.