【问题标题】:Amazon S3 Upload error SSL certificate issuesAmazon S3 上传错误 SSL 证书问题
【发布时间】:2016-12-04 15:55:49
【问题描述】:

我正在尝试在我的本地主机上测试 Laravel Amazon S3,但一直收到相同的错误:

WrappedHttpHandler.php 第 192 行中的 S3Exception:执行错误 “ListObjects”上 "https://s3-us-west-2.amazonaws.com/app?prefix=appimages%2FIMG-1469840859-j.jpg%2F&max-keys=1&encoding-type=url"; AWS HTTP 错误:cURL 错误 60:SSL 证书问题:无法获取 本地颁发者证书(请参阅 http://curl.haxx.se/libcurl/c/libcurl-errors.html)

我的代码:

$s3 = \Storage::disk('s3');
$filePath = '/images/' . $filename;
$s3->put($filePath, file_get_contents($image), 'public');

【问题讨论】:

  • 请访问此链接以了解 windows 用户 SSL 错误。 Link

标签: amazon-s3 laravel-5 amazon


【解决方案1】:

您已经对 php.ini 文件进行了调整。下载这个文件http://curl.haxx.se/ca/cacert.pem,像这样在php.ini中设置路径,然后重启服务器。

;;;;;;;;;;;;;;;;;;;;
; php.ini Options  ;
;;;;;;;;;;;;;;;;;;;;

curl.cainfo = "C:\xampp\php\extras\ssl\cacert.pem"

以上路径对于 XAAMP 很常见

这将解决您的问题。

【讨论】:

  • 我在 php.ini 中添加了 cacert.pem 文件路径,如下所示 [cURL] curl.cainfo='C:\xampp\cacert.pem' 但仍然显示相同的错误
  • 您确定路径与文件位置匹配
  • 是的,我确定还有其他步骤来设置路径吗?
  • 是windows还是linux?
  • 视窗。现在显示另一个错误 Error .executing "ListObjects" on "s3-us-west-2.amazonaws.com/…"; AWS HTTP 错误:cURL 错误 77:错误设置证书验证位置:CAfile:C:\cacert.pem CApath:无(请参阅curl.haxx.se/libcurl/c/libcurl-errors.html
【解决方案2】:
$s3 = new S3Client
         ([
            'version' => 'latest',
            'scheme' =>'http',
            'region'  => $this->config->item('s3_region'),
            'credentials' => [
                'key'    => $this->config->item('s3_access_key'),
                'secret' => $this->config->item('s3_secret_key')
            ],
        ]);

添加 'scheme' =>'http' 用于开发。

【讨论】:

    【解决方案3】:

    我遇到了同样的问题。 错误原因是您在本地或未经验证的服务器上工作。 只需要将以下行添加到“filesystem.php”

    'scheme' => 'http' // to disable SSL verification on local development
    

    您的 filesystem.php 应该如下所示:

    's3' => [
                'driver' => 's3',
                'key' => env('AWS_ACCESS_KEY_ID'),
                'secret' => env('AWS_SECRET_ACCESS_KEY'),
                'region' => env('AWS_DEFAULT_REGION'),
                'bucket' => env('AWS_BUCKET'),
                'url' => env('AWS_URL'),
                'scheme' => 'http' // to disable SSL verification on local development
            ],
    

    当您在具有 SSL 验证的服务器上运行它时,您需要注释 'scheme' 行。

    试试吧,你会发现它有效。 享受您的编码!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-08-30
      • 1970-01-01
      • 2020-09-18
      • 2022-01-26
      • 2012-08-08
      • 1970-01-01
      • 2019-12-11
      • 1970-01-01
      相关资源
      最近更新 更多