cagrit
By:
cagrit

SSL error Laravel 5.2 DO Spaces

November 14, 2017 90 views
Applications Ubuntu 16.04

I'm trying to move from S3 to Spaces on Laravel 5.2 Unfortunately, I keep getting SSL problem:

S3Exception in WrappedHttpHandler.php line 192:
Error executing "ListObjects" on "https://MYBUCKETNAME.ams3.digitaloceanspaces.com/?encoding-type=url"; AWS HTTP error: cURL error 60: SSL certificate problem: unable to get local issuer certificate (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)

.env

...
DO_SPACES_ENDPOINT=https://ams3.digitaloceanspaces.com
DO_SPACES_BUCKET=MYBUCKETNAME
DO_SPACES_REGION=ams3
DO_SPACES_KEY=******************
DO_SPACES_SECRET=******************************************************
...

filesystems.php

...
        'spaces' => [
            'driver' => 'do-spaces',
            'key' => env('DO_SPACES_KEY'),
            'secret' => env('DO_SPACES_SECRET'),
            'region' => env('DO_SPACES_REGION','ams3'),
            'bucket' => env('DO_SPACES_BUCKET'),
            'endpoint' => env('DO_SPACES_ENDPOINT'),
        ]
...

Service Provider:

<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;

use Aws\S3\S3Client;
use League\Flysystem\AwsS3v3\AwsS3Adapter;
use League\Flysystem\Filesystem;
use Storage;

class DOSpacesStorageServiceProvider extends ServiceProvider
{
    public function boot()
    {
      Storage::extend('do-spaces', function ($app, $config) {
          $client = new S3Client([
              'credentials' => [
                  'key'    => $config["key"],
                  'secret' => $config["secret"]
              ],
              'region'      => $config["region"],
              'version'     => "latest",
              'bucket_endpoint' => false,
              'use_path_style_endpoint' => false,
              'endpoint'    => $config["endpoint"],
          ]);
          return new Filesystem(new AwsS3Adapter($client, $config["bucket"]));
      });
    }
}

Be the first one to answer this question.