PHP执行Curl时报错提示CURL ERROR: Recv failure: Connection reset by peer的解决方法_php技巧

WBOY
Release: 2016-05-17 08:40:36
Original
3765 people have browsed it

最近在使用curl中遇到CURL ERROR: Recv failure: Connection reset by peer的报错提示,现把解决方法与大家共享,希望对大家有所帮助。

我们经常用curl来访问web站点,web站点目前主要分为http和https两种协议,众所周知https类型的网站都是通过ssl协议+http协议的,是目前最安全的网站协议,访问此类网站的时候,会走ssl协议,验证访问者的证书,检测是否安全。

通过curl访问此类网站也是如此流程,但是curl中需要添加相应的参数,绕过ssl证书的验证,才可以正常访问,如出现此错误的一般原因是没有加此参数(如下所示)。

curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($c, CURLOPT_SSL_VERIFYHOST, false);
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template