PHP Curl Common error: SSL error, BOOL (FALSE)

Source: Internet
Author: User
Tags ssl certificate

Symptom: Php Curl calls HTTPS error
Troubleshooting: Try using Curl on the command line.
Cause: The server's computer room cannot verify the SSL certificate.
Workaround: Skip the SSL certificate check.
curl_setopt ($ch, Curlopt_ssl_verifypeer, false);

Symptom: Php Curl call Curl_exec returns BOOL (false), command line curl is called normally.
How to troubleshoot:
Var_dump (Curl_error ($ch));
return:
string (Reply) "Empty from server"
Further troubleshooting: 
curl_setopt ($ch, Curlopt_header, true);
curl_setopt ($ch, Curlopt_returntransfer, false);
return: 
http/1.1 Continue
Connection:close
Cause: Php Curl received HTTP 100 is ended, should continue to receive HTTP
Solution: 
curl_setopt ($ch, Curlopt_httpheader, Array (' Expect: '));

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 included a very simple script to do. It had worked fine in the past, but is some reason barfed in this case. A closer look at what is being returned revealed that for some reason, Apache is prepending the ' normal ' headers with an Extra response Header:

http/1.1 Continue

http/1.1 OK Date:fri, June 2006 15:23:42 GMT
Server:apache
... A bit of googling revealed that this is to does with a header that is CURL sends by default:

expect: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 (' Expect: '));

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

Hope This helps someone.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.