Phpcurl common errors: SSL errors and bool (false ). Symptom: how to troubleshoot https call using phpcurl: use curl in the command line. Cause: The SSL certificate cannot be verified in the server room. Solution: Skip the SSL certificate check. Symptom: An error occurred while calling https in php curl.
Troubleshooting method: Use curl in the command line to call it.
Cause: The SSL certificate cannot be verified in the server room.
Solution: Skip the SSL certificate check.
Curl_setopt ($ ch, CURLOPT_SSL_VERIFYPEER, false );
Symptom: php curl calls curl_exec and returns bool (false). the command line curl call is normal.
Troubleshooting:
Var_dump (curl_error ($ ch ));
Return value:
String (23) "Empty reply from server"
Troubleshoot:
Curl_setopt ($ ch, CURLOPT_HEADER, true );
Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, false );
Return value:
HTTP/1.1 100 Continue
Connection: close
Cause: php curl ends when it receives HTTP 100. it should continue to receive HTTP 200.
Solution:
Curl_setopt ($ ch, CURLOPT_HTTPHEADER, array ('CT :'));
PHP and cURL: Disabling 100-continue header
Published June 15th, 2006
I 've been using cURL (through PHP) to build a sort of proxy for a project I'm working on. I need to parse the returned headers (to recover the HTTP status), so had has Ded a very simple script to do so. it had worked fine in the past, but for some reason barfed in this case. A closer look at what was being returned revealed that for some reason, Apache was prepending the 'normal' headers with an extra response header:
HTTP/1.1 100 Continue
HTTP/1.1 200 OK Date: Fri, 09 Jun 2006 15:23:42 GMT
Server: Apache
... A bit of Googling revealed that this was to do with a header that cURL sends by default:
Secondary CT: 100-continue
... Which in turns tells Apache to send the extra header. I poked around a fair bit but couldn't quite find a workable solution short of manually removing the header in PHP, which seemed a bit clumsy. finally, on a hunch I tried this:
Curl_setopt ($ curl_handle, CURLOPT_HTTPHEADER, array ('CT :'));
... Which basically overrides the original 'CT: 'header with an empty one.
Hope this helps someone.
Curl: use curl to call https. Cause: The SSL certificate cannot be verified in the server room. Solution: Skip the SSL certificate check ....