note 120169 added to function.curl-setopt-array
| From: | Alexander | Date: | Tue, 15 Nov 2016 12:14:54 +0000 |
| Subject: | note 120169 added to function.curl-setopt-array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-207109@lists.php.net to get a copy of this message | ||
Once upon a time I've got an error like "Problem with the SSL CA cert (path? access
rights?)". Since what I was doing was pretty much an administrative task with no actual
security issues involved, I decided to disallow certificate validation and this is where the most
interesting stuff began.
First I did it like this and it worked:
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
Next I thought, "But hey, I don't want any hardcoded stuff here. Let's use it in a
configurable way!". And so I did something like this:
// in configuration
$CURL_OPTIONS = array(CURLOPT_SSL_VERIFYPEER => 0, CURLOPT_SSL_VERIFYHOST => 0);
...........
// in place of two direct calls from earlier
curl_setopt_array($ch, $CURL_OPTIONS);
And I was so happy, there was no error anymore... and do you think I was happy for a long time? If
so, then you're wrong. It stopped giving an error, while it didn't start to work!
I checked the actual data but they were allright. Then I thought: "Is it the
curl_setopt_array() problem? Let's make it a cycle." The way it is mentioned in this help,
actually.
foreach ($CURL_OPTIONS as $name => $value)
{
curl_setopt($ch, $name, $value);
}
And... it did not work the same way as with the curl_setopt_array() call. And the data were still
allright...
So, if by chance you can't set CURL options with the curl_setopt_array() call, then now you
know what to do and you know it is definitely not you who is to blame.
P.S.
By the way, the configuration used was:
Linux i-ween.com 3.2.0-4-amd64 #1 SMP Debian 3.2.73-2+deb7u3 x86_64
PHP Version 5.5.17
----
Server IP: 72.52.91.14
Probable Submitter: 134.249.136.178
----
Manual Page -- http://php.net/manual/en/function.curl-setopt-array.php
Edit -- https://master.php.net/note/edit/120169
Del: integrated -- https://master.php.net/note/delete/120169/integrated
Del: useless -- https://master.php.net/note/delete/120169/useless
Del: bad code -- https://master.php.net/note/delete/120169/bad+code
Del: spam -- https://master.php.net/note/delete/120169/spam
Del: non-english -- https://master.php.net/note/delete/120169/non-english
Del: in docs -- https://master.php.net/note/delete/120169/in+docs
Del: other reasons-- https://master.php.net/note/delete/120169
Reject -- https://master.php.net/note/reject/120169
Search -- https://master.php.net/manage/user-notes.php