Phpcurl Common Errors: SSL errors, bool (false)

Source: Internet
Author: User
Tags http 200 ssl certificate
Use curl in the command line to call the method for skipping the SSL certificate check. For more information, see.

Use curl in the command line to call the method for skipping the SSL certificate check. For more information, see.

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.
Related Article

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.