Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

curl - PHP 35: error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure

cURL stopped working. I started to get this error (it used work fine till few hours ago).

I am using cURL extension for PHP. I found some solution for curl command line, but unfortunately i do not understand them :/ and I do not know how to move them to PHP cURl flags.

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);

error:

35: error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure

any ideas how to fix this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I just change from

curl_setopt($curl, CURLOPT_SSLVERSION, 3);

to

curl_setopt($curl, CURLOPT_SSLVERSION, 4);


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...