PHP curl错误:“未知SSL协议错误连接到...” [英] PHP curl error: "Unknown SSL protocol error in connection to..."

查看:793
本文介绍了PHP curl错误:“未知SSL协议错误连接到...”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对PHP curl有极大的困难。我正在尝试打开一个网站: https://www.novaprostaffing.com/np/index.jsp 通过PHP curl,但它仍然产生以下错误:未知的SSL协议错误连接到www.novaprostaffing.com

I having extreme difficulty with PHP curl. I am attempting to open a site: https://www.novaprostaffing.com/np/index.jsp through PHP curl, but it keeps yielding the following error: "Unknown SSL protocol error in connection to www.novaprostaffing.com"

我的功能如下:

function getUrl($url) {
$ch = curl_init();


curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate');


curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

$buffer = curl_exec($ch);

if (!$buffer)
   {
   echo "cURL error number:" .curl_errno($ch);
   echo " and url is $url and cURL error:" . curl_error($ch);

    }
curl_close($ch);
return $buffer;

}

包括:


  1. 将curl强制为版本3

  2. 设置CURLOPT_SSL_VERIFYPEER& CURLOPT_SSL_VERIFYHOST为0

  3. 检查是否显示curl 7.34。我被告知在这个版本有一个错误,但我是卷曲7.19.1

以上没有工作。

推荐答案

服务器仅使用TLS 1.0,并试图连接SSL 2.0或SSL 3.0会导致您看到的错误。这意味着将版本设置为3是这个服务器错误的事情。除此之外,证书链是不完整的。服务器只提供叶证书,而不是中间证书,直到受信任的根。这将导致验证失败。

The server speaks only TLS 1.0 and trying to connect with SSL 2.0 or SSL 3.0 will cause the error you see. This means setting the version to 3 is exactly the wrong thing with this server. Apart from that the certificate chain is incomplete. The server only provides the leaf certificate, not the intermediate certificates until the trusted root. This will cause verification to fail.

这篇关于PHP curl错误:“未知SSL协议错误连接到...”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆