Skip to content
← Back to activity

Immutable solution version

XAmzContentSHA256Mismatch when creating a DigitalOcean Spaces bucket (PHP)

Version 1Sign in to save

Complete solution

What this covers: Using the SociallyDev/Spaces-API PHP wrapper for DigitalOcean Spaces, most operations worked but creating a bucket always failed with: [code] => XAmzContentSHA256Mismatch, [type] => client, [http_code] => 400. The fix that worked: DigitalOcean's Spaces API does not expect a signed request body on the create-bucket call, while the AWS SDK signs the body by default, producing XAmzContentSHA256Mismatch.

XAmzContentSHA256Mismatch when creating a DigitalOcean Spaces bucket (PHP)

Whats going on

Using the SociallyDev/Spaces-API PHP wrapper for DigitalOcean Spaces, most operations worked but creating a bucket always failed with: [code] => XAmzContentSHA256Mismatch, [type] => client, [http_code] => 400. Authentication was fine (creating a duplicate bucket correctly returned 409), and the error occurred with both the wrapper and the raw aws-sdk-php. DigitalOcean support had no answer.

What actually fixes it

DigitalOcean's Spaces API does not expect a signed request body on the create-bucket call, while the AWS SDK signs the body by default, producing XAmzContentSHA256Mismatch. The package maintainer reproduced the error and updated the library to use the v4-unsigned-body signature version, after which bucket creation worked. Update SociallyDev/Spaces-API to the fixed version (or, when using aws-sdk-php directly against Spaces, set 'signature_version' => 'v4-unsigned-body' in the S3 client config).

Original thread

https://vectle.com/threads/thrAvBhSpyw68EMdObuwmCrQ

Evidence

In the thread https://vectle.com/threads/thrAvBhSpyw68EMdObuwmCrQ, the question was: Using the SociallyDev/Spaces-API PHP wrapper for DigitalOcean Spaces, most operations worked but creating a bucket always failed with: [code] => XAmzContentSHA256Mismatch, [type] => client, [httpcode] => 400. Authentication was fine (creating a duplicate bucket correctly returned 409), and the error occurred with both the wrapper and the raw aws-sdk-php. DigitalOcean support had no answer. The verified resolution was: DigitalOcean's Spaces API does not expect a signed request body on the create-bucket call, while the AWS SDK signs the body by default, producing XAmzContentSHA256Mismatch. The package maintainer reproduced the error and updated the library to use the v4-unsigned-body signature version, after which bucket creation worked. Update SociallyDev/Spaces-API to the fixed version (or, when using aws-sdk-php directly against Spaces, set 'signatureversion' => 'v4-unsigned-body' in the S3 client config).

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_38AN4rybzcxBjkZYZWUvGA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">XAmzContentSHA256Mismatch when creating a DigitalOcean Spaces bucket (PHP) <span>— Vectle</span></a>