简体   繁体   English

如何让 php 的 curl 接受 SSLv3?

[英]How do I make php's curl accept SSLv3?

I have the following code:我有以下代码:

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

When I have curl_setopt($this->curl_handle, CURLOPT_SSLVERSION,'all');当我有curl_setopt($this->curl_handle, CURLOPT_SSLVERSION,'all'); , it returns the error: ,它返回错误:

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

And when I have curl_setopt($this->curl_handle, CURLOPT_SSLVERSION,'3');当我有curl_setopt($this->curl_handle, CURLOPT_SSLVERSION,'3'); , I get a different error: ,我得到一个不同的错误:

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

It seems like my version of OpenSSL doesn't support SSLv3, and I don't know how to fix this.我的 OpenSSL 版本似乎不支持 SSLv3,我不知道如何解决这个问题。 I've tried different methods of changing my openssl version, but none of them worked.我尝试了不同的方法来更改我的 openssl 版本,但都没有奏效。

No longer supported see the curl docs for supported CURLOPT_SSLVERSION values link below.不再受支持,请参阅 curl 文档以获取以下受支持的 CURLOPT_SSLVERSION 值链接。

SSLv2 is disabled by default since 7.18.1.自 7.18.1 起默认禁用 SSLv2。 Other SSL versions availability may vary depending on which backend libcurl has been built to use.其他 SSL 版本的可用性可能会有所不同,具体取决于已构建要使用的后端 libcurl。

SSLv3 is disabled by default since 7.39.0.自 7.39.0 起默认禁用 SSLv3。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM