Skip to content

ListBuckets does not work on non-amazon services #171

Open
@SeventhCycle

Description

@SeventhCycle

Here is an code example that I have here while trying to connect to Linode's S3 cloud storage service:

	require 'includes/S3.php';
	ini_set("display_errors", "on");
	error_reporting(E_ALL);
	
	$AccessKey = "[REMOVED]"; //private info
	$SecretKey = "[REMOVED]"; //private info
	$EndPoint  = "us-east-1.linodeobjects.com";
	$Region = "us-east-1";
	
	$s3Client = new S3($AccessKey, $SecretKey);					
	if (isset($EndPoint)) $s3Client->setEndPoint($EndPoint);
	if (isset($Region)) $s3Client->setRegion($Region);
	$s3Client->setSSL(true);
	
	$buckets = $s3Client->listBuckets();

As a result, I get this error:
Warning: S3::listBuckets(): [403] Unexpected HTTP status in includes/S3.php on line 440

If I go into the file and print out the $rest object to get more information, I get:

stdClass Object
(
    [error] => 
    [body] => SimpleXMLElement Object
        (
            [Code] => SignatureDoesNotMatch
            [RequestId] => tx00000000000000471bbb4-005f306dbc-158bf75-default
            [HostId] => 158bf75-default-default
        )

    [headers] => Array
        (
            [date] => 1597009340
            [type] => application/xml
            [size] => 200
        )

    [code] => 403
)

On the other hand, if I change the above code to an amazon service:

	$AccessKey = "[REMOVED]";
	$SecretKey = "[REMOVED]";
	$EndPoint = "s3.amazonaws.com";
	$Region = "us-east-1";

Authentication works properly on Amazon's services.

Just to make sure this isn't a problem on Linode's end, I tried doing this on another third party (MojoCloud) and ran into the same issue.

Finally, just to make sure that the information is correct, I tried using aws-sdk-php beneath the tpyo library to see if I can connect to S3 using the same info:

	$credentials = new Aws\Credentials\Credentials($AccessKey, $SecretKey);

	$s3Client = new Aws\S3\S3Client([
		'region' => $Region,
		'version' => 'latest',
		'endpoint' => "https://" . $EndPoint,
		'credentials' => $credentials
		]);
		
	$result = $s3Client->listBuckets();
	
	echo "<PRE>";
	print_r($result["Buckets"]);
	exit;

And sure enough, this works for all three services (Amazon, MojoCloud, Linode). This way, I know the connection information is correct.

What I suspect here is a generalization problem with __getSignatureV4() where a valid signature is generated on amazon services, but not on non-amazon services.

Please let me know if any more information is needed here. If any of the maintainers here needs an access key / secret key to try troubleshooting this and debugging this on Linode's object service, please let me know.

Or if there's something obvious I'm missing, please let me know :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions