I am attempting to connect to a Digital Ocean Space from a Laravel 8 webapp using PHP 8. Whenever I try to upload a file, I get this error:

Aws\S3\Exception\S3Exception

Error executing "PutObject" on 
"//[MY-SPACE-NAME].ams3.digitaloceanspaces.com/[MY-SPACE-NAME].ams3.digitaloceanspaces.com"; 
AWS HTTP error: cURL error 60: SSL: no alternative certificate subject name matches target 
host name '[MY-SPACE-NAME].ams3.digitaloceanspaces.com' 
(see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for 
https://[MY-SPACE-NAME].ams3.digitaloceanspaces.com/[MY-SPACE-NAME].ams3.digitaloceanspaces.com

Here is my config file:

'spaces' => [
    'driver' => 's3',
    'key' => env('SPACES_KEY'),
    'secret' => env('SPACES_SECRET'),
    'endpoint' => env('SPACES_ENDPOINT'),
    'region' => env('SPACES_REGION'),
    'bucket' => env('SPACES_BUCKET'),
]

… and my .env file:

SPACES_KEY=****
SPACES_SECRET=****
SPACES_ENDPOINT=ams3.digitaloceanspaces.com
SPACES_BUCKET=[MY-SPACE-NAME]
SPACES_REGION=ams3

If I add “https://” to the start of the endpoint, it seems to want to prefix the space name before the protocol, ending up with this:
[MY-SPACE-NAME].https://ams3.digitaloceanspaces.com, which obviously throws up another error (cURL error 1).

In the other threads I’ve seen relating to this issue, the suggested solution has been to either uppercase the region (which has no effect in this case) or add ‘https://’ to the endpoint, which doesn’t work either. Prefixing 'https://’ to the space name yields the correct URL but the same error: cURL error 60. Usually this problem occurs on Windows-users’ local dev environments, so I can’t figure why this is happening in my case (both in my local dev environment on macOS and on a server running Ubuntu.

Some assistance would be most appreciated. Thanks.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

Hi there,

I think that I’ve seen a similar problem here:

https://www.digitalocean.com/community/questions/can-t-disable-ssl-on-space-curl-error-60-ssl-no-alternative-certificate

I believe that the error is occurring as you are not using https:// for your Spaces URL.

So you need to change http://**.fra1.digitaloceanspaces.com/1.txt to https://**.fra1.digitaloceanspaces.com/1.txt.

For more information, I would recommend following the steps here on how to integrating an S3-Compatible Object Storage into your Laravel Application:

https://www.digitalocean.com/community/tutorials/how-to-set-up-a-scalable-laravel-6-application-using-managed-databases-and-object-storage#step-5-%E2%80%94-integrating-an-s3-compatible-object-storage-into-the-application

Let me know how it goes!
Regards,
Bobby

by Bobby Iliev
by Erika Heidi
Data persistence and file storage represent two of the biggest challenges when horizontally scaling web applications. This is mainly due to the fact that it is hard to maintain consistency of variable data between multiple application nodes. A practical way of meeting these demands is by using managed databases and object storage. In this guide, we will update an existing Laravel 6 application to use a managed MySQL database and an S3-compatible object store.
  • Hi Bobby. Thanks for your answer.

    I would advise you to read the question more thoroughly before answering next time. I did state that I’ve been trying to add https:// to the endpoint URL but it does nothing to solve the problem. I’m not using http://, so I don’t know where you’re getting that.

    Yeah, I’ve seen the question and the guide you mention, but they dont help in solving my issue either unfortunately.

    Do you have any other explanation for why this could be happening?

    Thanks.

    • Hello,

      Are you using the league/flysystem-aws-s3-v3 package?

      If not, the package that you are using seems to be incompatibe, as the URL that it ends up using is basically incorrect as it is appended 2 times:

      https://[MY-SPACE-NAME].ams3.digitaloceanspaces.com/[MY-SPACE-NAME].ams3.digitaloceanspaces.com
      

      Here is an open-source project based on Laravel 8 that I’ve built a few months ago that uses the same implementation:

      https://github.com/guildso/guild

      The configuration is as follows:

      • S3 implementaiton with league/flysystem-aws-s3-v3
      • Settings in .env:
      DO_SPACES_KEY=MY_KEY
      DO_SPACES_SECRET=MY_SECRET
      DO_SPACES_ENDPOINT=https://fra1.digitaloceanspaces.com
      DO_SPACES_REGION=fra1
      DO_SPACES_BUCKET=my_space_name
      
      • The filesystems.php:
              'spaces' => [
                  'driver' => 's3',
                  'key' => env('DO_SPACES_KEY'),
                  'secret' => env('DO_SPACES_SECRET'),
                  'endpoint' => env('DO_SPACES_ENDPOINT'),
                  'region' => env('DO_SPACES_REGION'),
                  'bucket' => env('DO_SPACES_BUCKET'),
               ],
      

      It did not work without the https:// protocol specified in the spaces endpoint env variable. After adding the https:// and using dd it correctly constructed the hostname as follows:

      https://my_space_name.fra1.digitaloceanspaces.com
      

      Regards,
      Bobby

      • I am indeed using league/flysystem-aws-s3-v3. However, I think there was a mixup in both my local dev environment and on the server I was testing against. I’ve been juggling PHP 8 and PHP 7.4 lately and I think I accidentally ran composer update while PHP 7.4 was active. Later I switched to PHP 8 without updating the dependencies.

        I was beginning to suspect this was an issue on my end due to the scarcity of similar error reports lately.

        Thanks a bunch for taking the time to answer my question Bobby :-)