简体   繁体   English

Amazon Web Service S3显示SSL cURL错误

[英]Amazon Web Service S3 shows SSL cURL error

I'm trying to test in PHP Amazon S3 on my localhost on Ubuntu system but keep getting the same error: 我正在尝试在Ubuntu系统上的localhost上测试PHP Amazon S3但是仍然遇到同样的错误:

S3::listBuckets(): [35] error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol S3 :: listBuckets():[35]错误:140770FC:SSL例程:SSL23_GET_SERVER_HELLO:未知协议

It is the function to display bucket list. 它是显示桶列表的功能。

    public function buckets() {
            $s3 = $this->getInstance();
/*print_r($this->_s3->listBuckets()); nothing is print else shows error */
            return $this->_s3->listBuckets();


        }

Here is the Amazon API function that has been called by this function. 以下是此函数调用的Amazon API函数。

 public static function listBuckets($detailed = false) {
        $rest = new S3Request('GET', '', '');
        $rest = $rest->getResponse();
        if ($rest->error === false && $rest->code !== 200)
            $rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
        if ($rest->error !== false) {
            trigger_error(sprintf("S3::listBuckets(): [%s] %s", $rest->error['code'], $rest->error['message']), E_USER_WARNING);
            return false;
        }
        $results = array();
        if (!isset($rest->body->Buckets))
            return $results;

        if ($detailed) {
            if (isset($rest->body->Owner, $rest->body->Owner->ID, $rest->body->Owner->DisplayName))
                $results['owner'] = array(
                    'id' => (string) $rest->body->Owner->ID, 'name' => (string) $rest->body->Owner->ID
                );
            $results['buckets'] = array();
            foreach ($rest->body->Buckets->Bucket as $b)
                $results['buckets'][] = array(
                    'name' => (string) $b->Name, 'time' => strtotime((string) $b->CreationDate)
                );
        }
        else
            foreach ($rest->body->Buckets->Bucket as $b)
                $results[] = (string) $b->Name;

        return $results;
    }

It seems that you have changed your PHP version as this bug is occurred several time in PHP 5.4 but it works perfectly in previous versions. 您似乎已经更改了PHP版本,因为这个错误在PHP 5.4中发生了几次,但它在以前的版本中完美运行。 You can re-install cURL with Open SSL again. 您可以再次使用Open SSL重新安装cURL。

It is most common error occurred in integration of AWS S3 on localhost. 在localhost上集成AWS S3是最常见的错误。

  1. Check is cURL is enable and Open SSL is also active. 检查是cURL已启用且Open SSL是否也处于活动状态。
  2. Get file from http://curl.haxx.se/ca/cacert.pem and save it to your libraries at hard drive. http://curl.haxx.se/ca/cacert.pem获取文件并将其保存到硬盘驱动器中的库中。 Rename it cacert.pem. 将其重命名为cacert.pem。
  3. Configure curl.cainfo in php.ini with the full path to the file downloaded in step 2. 使用步骤2中下载的文件的完整路径在php.ini中配置curl.cainfo。
  4. Restart Apache. 重启Apache。

It will be worked perfectly. 它将完美地运作。

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

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