Goutte - TLSv1 协议版本错误


Goutte - TLSv1 protocol version error

我正在使用Goutte使用SSL证书在Web服务器上获取页面。每当我尝试获取此页面时,都会抛出以下异常:

Uncaught exception 'Guzzle''Http''Exception''CurlException' with message 
'[curl] 35: error:1407742E:SSL 
routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version 
[url] https://somesite.com 

我一直在网上寻找这种类型的错误。似乎当握手失败时会发生此错误。服务器似乎支持 TLSv1,客户端使用 SSL23。

我不确定这个评估是否正确,也不知道如何纠正它。

这是我当前使用的代码:

<?php
use Goutte'Client;
$client = new Client();
$guzzle = $client->getClient();
$guzzle->setConfig( 
    array(
        'curl.CURLOPT_SSL_VERIFYHOST' => false,
        'curl.CURLOPT_SSL_VERIFYPEER' => false,
    )
);
$client->setClient($guzzle);
$crawler = $client->request('GET', 'https://somesite.com'); // IT FAILS HERE

更新:

注意:几周前我开始收到类似的错误,所以我想我会更新问题和答案,因为它们是相关的。

我遇到了类似的错误:

[curl] 35: Unknown SSL protocol error in connection to website.com:443 

我在博客文章"使用 PHP5 和 Curl 修复 SSL 握手"中找到了这个问题的答案

此错误可能会在某些操作系统中发生,但并非全部都发生,使其成为难以复制的问题。我目前正在开发环境中使用 Ubuntu 12.04。

值得庆幸的是,这是可以在代码级别解决的问题,如下所示:

use Goutte'Client;
$client = new Client();
$guzzle = new GuzzleClient('https://somesite.com', array(
    'curl.options' => array(
        'CURLOPT_SSLVERSION' => 'CURL_SSLVERSION_TLSv1',
    )
));
$client->setClient($guzzle);
$crawler = $client->request('GET', 'https://somesite.com');

更新:

对于消息的解决方案

[curl] 35: Unknown SSL protocol error in connection to website.com:443 

有点棘手,因为消息没有指示正在发生的事情。

这个 GitHub 问题为我指明了正确的方向。我可以使用多个版本的CURLOPT_SSLVERSION(当然!),但这些版本包括 v1.0、v1.1 和 v1.2!有关详细信息,请参阅curl_setopt。

对于这个特定的错误,我最终使用以下代码:

$guzzle = new GuzzleClient('https://somesite.com', array(
    'curl.options' => array(
        'CURLOPT_SSLVERSION' => 'CURL_SSLVERSION_TLSv1_1',
    )
));

我尝试连接的站点不接受任何其他选项,包括CURL_SSLVERSION_TLSv1