【问题标题】:How do I make php's curl accept SSLv3?如何让 php 的 curl 接受 SSLv3?
【发布时间】:2021-02-18 23:28:31
【问题描述】:

我有以下代码:

curl_setopt($this->curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($this->curl_handle, CURLOPT_SSLVERSION,'all'); 
curl_setopt($this->curl_handle, CURLOPT_SSL_VERIFYPEER, false);

    // set the file to be uploaded
    if (!curl_setopt($this->curl_handle, CURLOPT_FILE, $fp_to_download)) {
        throw new Exception("Could not download file $local_file");
    }

    // download file
    try {
        if (!curl_exec($this->curl_handle)) {
            throw new Exception(sprintf('Could not download file. cURL Error: [%s] - %s', curl_errno($this->curl_handle), curl_error($this->curl_handle)));
        }
    } catch (Exception $e) {
        $error_msg = $e->getMessage();
        // Fallback to cUrl upload
        if (strpos($error_msg, 'SSL23_GET_SERVER_HELLO')) {
            return $this->curlProcessHandler('ftp://'.preg_replace('#/+#', '/', $this->server.':'.$this->port.'/'.$remote_file), $local_file);
        } else {
            throw new Exception("Could not download file $remote_file: $error_msg");
        }
    }

当我有curl_setopt($this->curl_handle, CURLOPT_SSLVERSION,'all'); 时,它返回错误:

Could not download file. cURL Error: [35] - error:1408F10B:SSL routines:ssl3_get_record:wrong version number

当我有curl_setopt($this->curl_handle, CURLOPT_SSLVERSION,'3'); 时,我得到一个不同的错误:

Could not download file. cURL Error: [4] - OpenSSL was built without SSLv3 support

我的 OpenSSL 版本似乎不支持 SSLv3,我不知道如何解决这个问题。 我尝试了不同的方法来更改我的 openssl 版本,但都没有奏效。

【问题讨论】:

  • 你没有。您更新任何试图使用 SSLv3 的内容,因为它已经过时且危险。作为参考,SSLv3 支持已于 2014 年 11 月从 Firefox 中移除,因为存在巨大且无法修补的安全漏洞。

标签: php curl openssl


【解决方案1】:

不再受支持,请参阅下面的 curl 文档以获取支持的 CURLOPT_SSLVERSION 值链接。

自 7.18.1 起默认禁用 SSLv2。其他 SSL 版本的可用性可能会有所不同,具体取决于构建使用的后端 libcurl。

自 7.39.0 起默认禁用 SSLv3。

https://curl.se/libcurl/c/CURLOPT_SSLVERSION.html

【讨论】:

  • 谢谢。我找到了一个不涉及 php curl 的问题的解决方法。
猜你喜欢
  • 2016-05-07
  • 2022-01-02
  • 1970-01-01
  • 2014-05-27
  • 2014-12-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多