PHP 35:错误:14094410:SSL例程:SSL3_READ_BYTES:sslv3警报握手失败

时间:2014-05-09 15:32:14

标签: php curl

cURL停止了工作。我开始得到这个错误(直到几个小时前才使用它。)

我正在使用PHP的cURL扩展。我找到了curl命令行的一些解决方案,但不幸的是我不理解它们:/我不知道如何将它们移动到PHP cURl标志。

cURL conf:

$curl=curl_init();
curl_setopt($curl, CURLOPT_URL, "https://pln.bitcurex.com/data/ticker.json");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_SSLVERSION, 3);
curl_setopt($curl, CURLOPT_TIMEOUT, 10);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_USERAGENT, $this->useragent);
curl_setopt($curl, CURLOPT_VERBOSE, 0);
curl_setopt($curl, CURLOPT_HEADER, FALSE);
curl_setopt($curl, CURLOPT_HTTPHEADER, $this->headers);

if(substr($url, 0, 5)=='https') curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);

if($this->ciastko)
{
    curl_setopt($curl, CURLOPT_COOKIEJAR, $this->ciastko);
    curl_setopt($curl, CURLOPT_COOKIEFILE, $this->ciastko);
}

if($this->post)
{
    if( is_array($this->post) && count($this->post) > 0 )
    {
        $postdata = http_build_query($this->post,'','&');
    }
    elseif( is_string($this->post) )
    {
        $postdata = $this->post;
    }
    else $postdata = '';

    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
}

$wynik=curl_exec($curl);

错误:

35:错误:14094410:SSL例程:SSL3_READ_BYTES:sslv3警报握手失败

任何想法如何解决这个问题?

3 个答案:

答案 0 :(得分:12)

我只是从

改变
  

curl_setopt($ curl,CURLOPT_SSLVERSION,3);

  

curl_setopt($ curl,CURLOPT_SSLVERSION,4);

答案 1 :(得分:10)

我知道这有点过时的问题,但我有其他人的解决方案:

curl_setopt($ch, CURLOPT_SSLVERSION, 3);
curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, 'SSLv3');

答案 2 :(得分:0)

输入值:

$params = Array
    (
        "username" => "XXXXXXXXXX",
        "password" => "XXXXXX"
    );

$path ='https://www.XXXXXXXX.com/xx/xxx/format/json/';

<强>功能:

function curlpost($parameters, $path){
     $apiUrl = $path;
     $curl_handle = curl_init();
     curl_setopt($curl_handle, CURLOPT_URL, $apiUrl);
     curl_setopt($curl_handle, CURLOPT_BUFFERSIZE, 1024);
     curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, TRUE);
     curl_setopt($curl_handle, CURLOPT_SSL_VERIFYPEER, TRUE);
     curl_setopt($curl_handle, CURLOPT_SSL_VERIFYHOST, TRUE);
     curl_setopt($curl_handle, CURLOPT_POST, TRUE);
     curl_setopt($curl_handle, CURLOPT_PROXY, '');
     curl_setopt($curl_handle, CURLOPT_SSLVERSION, 4);
     curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $parameters);
     $response = curl_exec($curl_handle);

     $content = curl_exec( $curl_handle );
     $err     = curl_errno( $curl_handle );
     $errmsg  = curl_error( $curl_handle );
     $header  = curl_getinfo( $curl_handle );
     curl_close( $curl_handle );

     $header['errno']   = $err;
     $header['errmsg']  = $errmsg;
     $header['content'] = $content;
    curl_close($curl_handle);
     return $header;
 }