php curl常见错误:SSL错误、bool(false)
来源:互联网 发布:手机域名注册证书 编辑:程序博客网 时间:2024/06/06 07:27
症状:php curl调用https出错
排查方法:在命令行中使用curl调用试试。
原因:服务器所在机房无法验证SSL证书。
解决办法:跳过SSL证书检查。
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
症状:php curl调用curl_exec返回bool(false),命令行curl调用正常。
排查方法:
var_dump(curl_error($ch));
返回:
string(23) "Empty reply from server"
再排查:
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
返回:
HTTP/1.1 100 Continue
Connection: close
原因:php curl接收到HTTP 100就结束了,应该继续接收HTTP 200
解决方案:
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 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:
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.
排查方法:在命令行中使用curl调用试试。
原因:服务器所在机房无法验证SSL证书。
解决办法:跳过SSL证书检查。
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
症状:php curl调用curl_exec返回bool(false),命令行curl调用正常。
排查方法:
var_dump(curl_error($ch));
返回:
string(23) "Empty reply from server"
再排查:
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
返回:
HTTP/1.1 100 Continue
Connection: close
原因:php curl接收到HTTP 100就结束了,应该继续接收HTTP 200
解决方案:
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 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:
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.
阅读全文
0 0
- php curl常见错误:SSL错误、bool(false)
- php curl常见错误:SSL错误、bool(false)
- php curl常见错误:SSL错误、bool(false)
- php curl常见错误:SSL错误、bool(false)
- php curl常见错误:SSL错误、bool(false)
- php curl常见错误:SSL错误、bool(false)
- curl常见错误:SSL错误、bool(false)
- curl返回常见错误码
- Curl常见错误返回码
- curl返回常见错误码
- curl返回常见错误码
- curl返回常见错误码
- curl返回常见错误码
- curl返回常见错误码
- 常见SSL错误和解决办法
- 关于php curl 请求https 报ssl证书错误的解决方案
- php curl请求https接口返回curl: (60) SSL certificate problem: unable to get local issuer certificate 错误
- php开发常见错误
- 关于css的独立打包
- SecureCRT乱码问题解决
- java获取路径
- 关于html<head>部分怎么写的一些思考
- caffe/common.cu error: function atomicadd has already been defined
- php curl常见错误:SSL错误、bool(false)
- Spark之 KryoSerializer序列化
- 从容器之热看新时代的虚拟化技术
- dijit/form/FilteringSelect 的使用记录
- C#Linq 基本操作实例
- 在Android studio3.0 用kotlin语言开发Android app demo
- 基本算法------枚举
- RCFile和ORCFile
- 1034. Head of a Gang (30) <广搜>