Common php curl errors: SSL error bool of false

  • 2020-05-10 17:52:11
  • OfStack

Symptoms: an error occurred when php curl called https
Troubleshooting method: try using the curl call from the command line.
Reason: the SSL certificate could not be verified in the server room.
Solution: skip the SSL certificate check.
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

Symptoms: php curl calls curl_exec return bool(false), command line curl calls normal.
Screening method:
var_dump(curl_error($ch));
Returns:
string(23) "Empty reply from server"
Screen:
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
Returns:
HTTP/1.1 100 Continue
Connection: close
Reason: php curl ends when it receives HTTP 100 and should continue to receive HTTP 200
Solutions:
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));

PHP and cURL: Disabling 100-continue header
Published June 15th, 2006
I've been es552 (through PHP) to build a of of I I m working on I need the returned headers to recover the HTTP status), so had included simple script to do so It had worked fine in the past but for some barfed in this case.A closer at what was returned revealed for some reason Apache was prepending the 'normal' 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:

Expect: 100-continue

... which in tells to the the the the couldn t find workable short of manually the header PHP, which seemed a bit hunch tried this

curl_setopt( $curl_handle, CURLOPT_HTTPHEADER, array( 'Expect:' ) );

... which basically overrides the original 'Expect:' header with an empty one.

Hope this helps someone.

Related articles: