解决curl: 35 – error:14077410

作者: harde 分类: PHP,开发相关 发布时间: 2015-02-27 13:47

在某项目中,使用curl请求带ssl身份验证的API时出现了这个问题。
完整的错误信息是:

curl: 35 – error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure

度娘了半天也没查出个所以然。
然后莫名其妙的在DA的help中看到了解决办法。

If you’re running curl 7.35.0 and run into this error in php when trying to connect to a remote host:

35 – error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure
it means you need to tell curl to use sslv3 and also use the sslv3 ciphers, ensure you have these curl_setopt settings, eg:

curl_setopt($ch, CURLOPT_SSLVERSION, 3);
curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, ‘SSLv3’);

好了,问题解决。

另外,如果是使用GuzzleHttp
可以这样设置

$cfg = [
    'config' => [
            'curl' => [
                CURLOPT_SSLVERSION => 3,
                CURLOPT_SSL_CIPHER_LIST  => 'SSLv3'
            ]
    ]
];
$client->post('/xxx',$cfg);

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注