douchen2011 2015-10-20 05:15
浏览 514

PHP Curl Error 35 Peer报告它遇到内部错误

I am trying to get PHP Curl working using the following code: I own the domain that is using the api and I can make any changes to the server that it is running on.

<?php
ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(-1);

$data = array("username" => "derped", "authid" => "987654321", "ipaddress" => "1.2.3.4", "apikey" => "1234567829");
$data_string = json_encode($data);
$url = 'https://www.somedomain.com/test/api.php';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: Content-Type: text/html'));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
if(curl_exec($ch) === false)
{
    echo curl_error($ch);
}
else
{
    echo 'ok';
}

curl_close($ch);

$received = json_decode($result);
$check = $received->{'good'};
echo $result;
echo $check;
?>

Curl returns the error: Peer reports it experienced an internal error. When I curl the domain itself (https://www.somedomain.com) it returns the same error. Even when I use curl via the terminal it returns the 35 error, but when I try to curl the domain without HTTPS it returns the 302 found but since my domain is https only this will not be the solution, it just echos the move page. I know this has something todo with curl using https but https://www.google.com works so I dont know where to start...

  • 写回答

3条回答 默认 最新

  • duandu8892 2015-10-20 05:26
    关注

    Below is an answer in from php.net. Apparently it should help solve the unknown protocol issue...

    If you get an error with the error code 35 saying "Unknown SSL protocol error in connection to ...", maybe you are using the wrongs ciphers.

    Try to precise a bunch of ciphers as below:

    $arrayCiphers = array(
        'DHE-RSA-AES256-SHA',
        'DHE-DSS-AES256-SHA',
        'AES256-SHA:KRB5-DES-CBC3-MD5',
        'KRB5-DES-CBC3-SHA',
        'EDH-RSA-DES-CBC3-SHA',
        'EDH-DSS-DES-CBC3-SHA',
        'DES-CBC3-SHA:DES-CBC3-MD5',
        'DHE-RSA-AES128-SHA',
        'DHE-DSS-AES128-SHA',
        'AES128-SHA:RC2-CBC-MD5',
        'KRB5-RC4-MD5:KRB5-RC4-SHA',
        'RC4-SHA:RC4-MD5:RC4-MD5',
        'KRB5-DES-CBC-MD5',
        'KRB5-DES-CBC-SHA',
        'EDH-RSA-DES-CBC-SHA',
        'EDH-DSS-DES-CBC-SHA:DES-CBC-SHA',
        'DES-CBC-MD5:EXP-KRB5-RC2-CBC-MD5',
        'EXP-KRB5-DES-CBC-MD5',
        'EXP-KRB5-RC2-CBC-SHA',
        'EXP-KRB5-DES-CBC-SHA',
        'EXP-EDH-RSA-DES-CBC-SHA',
        'EXP-EDH-DSS-DES-CBC-SHA',
        'EXP-DES-CBC-SHA',
        'EXP-RC2-CBC-MD5',
        'EXP-RC2-CBC-MD5',
        'EXP-KRB5-RC4-MD5',
        'EXP-KRB5-RC4-SHA',
        'EXP-RC4-MD5:EXP-RC4-MD5');
    curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, implode(':', $arrayCiphers));
    

    Worked for me, could work for you! P.S: Used with PHP 5.4 and cURL 7.26.0.

    评论

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记