簡體   English   中英

Amazon Web Service S3顯示SSL cURL錯誤

[英]Amazon Web Service S3 shows SSL cURL error

我正在嘗試在Ubuntu系統上的localhost上測試PHP Amazon S3但是仍然遇到同樣的錯誤:

S3 :: listBuckets():[35]錯誤:140770FC:SSL例程:SSL23_GET_SERVER_HELLO:未知協議

它是顯示桶列表的功能。

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


        }

以下是此函數調用的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;
    }

您似乎已經更改了PHP版本,因為這個錯誤在PHP 5.4中發生了幾次,但它在以前的版本中完美運行。 您可以再次使用Open SSL重新安裝cURL。

在localhost上集成AWS S3是最常見的錯誤。

  1. 檢查是cURL已啟用且Open SSL是否也處於活動狀態。
  2. http://curl.haxx.se/ca/cacert.pem獲取文件並將其保存到硬盤驅動器中的庫中。 將其重命名為cacert.pem。
  3. 使用步驟2中下載的文件的完整路徑在php.ini中配置curl.cainfo。
  4. 重啟Apache。

它將完美地運作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM