php - 服务器出现 curl "Unknown SSL protocol error in connection"错误,但在本地有效

标签 php curl ssl

我正在尝试使用以下代码从站点(我已经审查了 url)检索数据:

<?php 

  $url = [doesnt really matter];

  $ch = curl_init();

  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

  $archivo_xml = fopen("test.tst", "w");

  curl_setopt($ch, CURLOPT_FILE,$archivo_xml);

  curl_exec($ch);
  $as1 = curl_getinfo($ch, CURLINFO_NAMELOOKUP_TIME);
  $as2 = curl_getinfo($ch, CURLINFO_CONNECT_TIME);
  $as3 = curl_getinfo($ch, CURLINFO_PRETRANSFER_TIME);
  $as4 = curl_getinfo($ch, CURLINFO_STARTTRANSFER_TIME);
  $as5 = curl_getinfo($ch, CURLINFO_TOTAL_TIME);

  echo "Lookup: ",$as1," \n\r Connect: ",$as2," \n\r Pretransfer: ",$as3," \n\r Starttransfer: ",$as4," \n\r Total: ",$as5,"\n\r","Error: ", curl_error($ch), "\n\r";

  curl_close($ch);
  fclose($archivo_xml);

?>

它在本地工作正常,但在服务器上却不行。这是本地的输出:

Lookup: 0.015155 
 Connect: 0.0281 
 Pretransfer: 0.129087 
 Starttransfer: 0.786341 
 Total: 0.786384
Error:

这是服务器的输出:

Lookup: 0.028731 
 Connect: 0.043182 
 Pretransfer: 0 
 Starttransfer: 0 
 Total: 60.057787
Error: Unknown SSL protocol error in connection to [censored url] 

任何其他 url 都可以正常工作,问题出在这个特定的 url 上。

本地主机 PHP 版本:5.4.23

服务器PHP版本:5.5.7

提前致谢

最佳答案

尝试设置 cURL 参数

curl_setopt($ch, CURLOPT_SSLVERSION,3); // Apparently 2 or 3

关于php - 服务器出现 curl "Unknown SSL protocol error in connection"错误,但在本地有效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20988782/

相关文章:

php - 将随机文件下载为 zip

php - 将 id 更新为 max(id)+1

php - 引用类变量作为 PHP 函数中的默认参数

web-services - Tomcat - WebService - 没有信任库

c# - 重置 ServerCertificateValidationCallback

django - 如何让游戏在通过 facebook 玩时使用 https,在从其他域玩时使用 http

php - fatal error : Class 'Memcache' not found (installed with pecl)

php - SSL/cUrl/PHP 请求在 Zend 服务器中失败

php - 除了 CURLOPT_COOKIEFILE 之外,如何使用 PHP curl 发送 cookie?

php - 如何处理 php 生成的图像(不带扩展名)?