Curl POST to HTTPS url gives SSLRead() error:curl: (56) SSLRead() return error -9806

简介: 当系统升级到OSX 10.10.3的时候,用brew更新软件安装包,出现了curl抛出的错误。 ==> Upgrading boost ==> Downloading https://homebrew.

当系统升级到OSX 10.10.3的时候,用brew更新软件安装包,出现了curl抛出的错误。


==> Upgrading boost
==> Downloading https://homebrew.bintray.com/bottles/boost-1.58.0.yosemite.bottle.tar.gz
                                                                           0.7%
curl: (56) SSLRead() return error -9806
Error: Failed to download resource "boost"

起初,以为是宽带的问题,据说某宽带在使用过程中老是插入广告,竟连curl抓取数据包都难免植入广告。


如果是宽带的问题,应该说curl获取一切信息都会出错,经尝试,对于http协议的请求都是fine的,那么尝试https协议,发现github也是好的,可以收到数据。但是,一旦请求的https的具体的某一个包的时候,出现curl(56)错误:

error:curl: (56) SSLRead() return error -9806

查询得知:curl(56)错误是----CURL_RECV_ERROR:Failure with receiving network data.

意思很明确了:curl接收网络数据失败。


最后的最后,只能从网上获取答案:很幸运,有人比我早遇到此类问题:

在stackoverflow上有篇名为《osx 10.10 Curl POST to HTTPS url gives SSLRead() error


I just recently upgraded to OSX 10.10 Yosemite and I since the upgrade I can't do Curl POST to a SSL url anymore.

I first used wordpress' wp_remote_request call and also tried to use curl in php.Both (as expected) give the same error message:

Error Number:56Error String:SSLRead() return error -9806

Note: when I curl POST to HTTP it works fine.I reckon it is a setting in PHP.ini or in my apache (I lost my original HTTPD.conf file after upgrade...).

Can anyone help me out?


这是被采取的答案:

I've seen this error happen when php is compiled with a version of cURL that usesApple's Secure Transport under Yosemite and the target of the URL request doesn't support SSLv3 (which was probably disabled due to thePOODLE vulnerability). What is the output of this command?

$ php -i | grep "SSL Version"

I suspect you'll see this:

SSL Version => SecureTransport

You can overcome this by installing a version of php which uses a version of cURL which uses OpenSSL instead of SecureTransport. This is most easily done withhomebrew. So install that first if you don't already have it. If homebrew is installed but you haven't runbrew update since upgrading to Yosemite, do that first. Also make sure you've installed XCode >= 6.1 and the latest XCode command line tools.brew doctor will tell you if you've done it all right.

Add the Homebrew taps below that you will need in order to get brewed php installed. Skip this step if these repos are already tapped. If you're unsure if these repos are already tapped, just run the commands below. Worst case scenario, you'll get a harmlessWarning: Already tapped!

$ brew tap homebrew/dupes
$ brew tap homebrew/versions
$ brew tap homebrew/php

Then install curl with openssl:

$ brew install --with-openssl curl

Then install php using the curl you just installed and brewed openssl:

$ brew install \
    --with-apache \
    --with-homebrew-curl \
    --with-homebrew-openssl \
    --without-snmp php55
  • if you're running nginx change --with-apache to --with-fpm.
  • the --without-snmp is necessary because of issue #1311.
  • if using apache, make sure to add LoadModule php5_module /usr/local/opt/php55/libexec/apache2/libphp5.so to your/etc/apache2/httpd.conf and restart apache.

Install any php extensions you're going to need eg. mcrypt.

$ brew install php55-mcrypt

After you're done, run this again:

$ php -i | grep "SSL Version"

And you should see:

SSL Version => OpenSSL/1.0.1j

And now, re-test your application and the SSLRead() return error -9806 should go away.


大概意思:

先使用命令

php -i |grep "SSL Version"

看看SSL Version的信息,猜想你看到是:

SSL Version => SecureTransport

那么,就可以按照下面的命令去做:

$ brew tap homebrew/dupes

$ brew tap homebrew/versions

$ brew tap homebrew/php

有可能会出现不伤大雅的警告信息:Already tapped!

重点来了:

然后使用openssl安装curl,这就是要替换掉原来的curl,命令如下:

$ brew install --with-openssl curl
然后使用刚才安装的curl和openssl安装php:
$ brew install \
    --with-apache \
    --with-homebrew-curl \
    --with-homebrew-openssl \
    --without-snmp php55
  • 如果你想运行nginx,将 --with-apache 改为--with-fpm.
  • 因为 issue #1311的缘故,--without-snmp是必须.
  • 如果使用apache,确保添加 LoadModule php5_module /usr/local/opt/php55/libexec/apache2/libphp5.so到/etc/apache2/httpd.conf并重启apache.

安装你需要的php的其他扩展,例如 : mcrypt.

$ brew install php55-mcrypt

完成后,再次运行下面的命令:

$ php -i | grep "SSL Version"

你会看到:

SSL Version => OpenSSL/1.0.1j


好吧,这个问题就这样解决了。


目录
相关文章
|
6月前
|
Java
百度搜索:蓝易云【hutool Http 工具发送POST请求的几种方式。】
以上是使用Hutool发送POST请求的几种方式。根据实际需求和代码复杂度,选择合适的方式来发送POST请求。
184 0
|
7月前
|
JSON 前端开发 数据格式
【前后端异常】http/https post请求 返回415错误状态码的解决方法
【前后端异常】http/https post请求 返回415错误状态码的解决方法
1106 0
|
4小时前
|
JavaScript
Node.js【GET/POST请求、http模块、路由、创建客户端、作为中间层、文件系统模块】(二)-全面详解(学习总结---从入门到深化)(上)
Node.js【GET/POST请求、http模块、路由、创建客户端、作为中间层、文件系统模块】(二)-全面详解(学习总结---从入门到深化)
32 0
|
4小时前
|
XML JSON Java
Android App网络通信中通过okhttp调用HTTP接口讲解及实战(包括GET、表单格式POST、JSON格式POST 附源码)
Android App网络通信中通过okhttp调用HTTP接口讲解及实战(包括GET、表单格式POST、JSON格式POST 附源码)
219 0
|
4小时前
|
Kubernetes 容器
使用kubeadm部署k8s报错:The kubelet is not running或者level=error msg="Handler for POST /v1.43/images/create returned error: Head \"https://us-west2-dock
使用kubeadm部署k8s报错:The kubelet is not running或者level=error msg="Handler for POST /v1.43/images/create returned error: Head \"https://us-west2-dock
|
4小时前
|
Python
pytho3 urllib urllib3 获取本地ip地址和mac地址发送post到指定http服务器
pytho3 urllib urllib3 获取本地ip地址和mac地址发送post到指定http服务器
34 0
|
4小时前
|
Python
pytho2 urllib urllib2 获取本地ip地址和mac地址发送post到指定http服务器
pytho2 urllib urllib2 获取本地ip地址和mac地址发送post到指定http服务器
19 0
|
4小时前
|
JavaScript Java Serverless
函数计算中,这里是用的curl的方式,如何改用http的post方式请求?还有如何设置oss打包的zip的保存目录?
函数计算中,这里是用的curl的方式,如何改用http的post方式请求?还有如何设置oss打包的zip的保存目录?
161 0
|
4小时前
|
JavaScript Serverless Python
在函数计算中如何查看HTTP的post内容?
在函数计算中如何查看HTTP的post内容?
468 0
|
4小时前
restTemplate 发送http post请求带有文件流、参数
restTemplate 发送http post请求带有文件流、参数
74 1