Edited to fix typo: I use an AWS S3 bucket to store files in a Laravel project. It worked fine, and then I had to move the bucket to a new region. As far as I remember, it worked fine, but now it throws an error when I use PutObject(). I get errors, even after switching back to the previous region.
This is how I have configured the S3 driver in filesystems.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'),
'endpoint' => env('AWS_ENDPOINT'),
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
'throw' => true,
],
And this is my .env file for using S3
AWS_ACCESS_KEY_ID=AKIA23ECJX*****
AWS_SECRET_ACCESS_KEY=*******noVeTOWVgBPibqz0******
AWS_DEFAULT_REGION=ca-central-1
AWS_BUCKET=silkweb-canada
AWS_URL=https://silkweb-canada.s3.ca-central-1.amazonaws.com
AWS_ENDPOINT=https://silkweb-canada.s3.ca-central-1.amazonaws.com
AWS_USE_PATH_STYLE_ENDPOINT=false
AWS_S3_SILKWEB_URL="https://silkweb-canada.s3.ca-central-1.amazonaws.com/"
And when I use PutObject(), I get the following error:
Unable to write file at location: client/temp/99. Error executing "PutObject" on "https://ift.tt/aVpOBAw"; AWS HTTP error: cURL error 60: SSL: no alternative certificate subject name matches target host name 'silkweb-canada.silkweb-canada.s3.ca-central-1.amazonaws.com' (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://silkweb-canada.silkweb-canada.s3.ca-central-1.amazonaws.com/client/temp/99 {"userId":2,"exception":"[object] (League\Flysystem\UnableToWriteFile(code: 0): Unable to write file at location: client/temp/99. Error executing "PutObject" on "https://ift.tt/aVpOBAw"; AWS HTTP error: cURL error 60: SSL: no alternative certificate subject name matches target host name 'silkweb-canada.silkweb-canada.s3.ca-central-1.amazonaws.com' (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://silkweb-canada.silkweb-canada.s3.ca-central-1.amazonaws.com/client/temp/99 at /var/www/vhosts/app.silkweb.ca/vendor/league/flysystem/src/UnableToWriteFile.php:24)
What I find surprising is that is that my bucket name (silkweb-canada) is being prefixed in the host name: AWS_URL=AWS_URL=https://ift.tt/gIN8vRc becomes https://silkweb-canada.silkweb-canada.s3.ca-central-1.amazonaws.com/client/temp/99
I am grateful for any suggestion to fix the issue.
source https://stackoverflow.com/questions/77434385/error-using-putobject-to-write-a-file-in-an-aws-s3-in-laravel
No comments:
Post a Comment