aws-sdk-go-v2 icon indicating copy to clipboard operation
aws-sdk-go-v2 copied to clipboard

New S3 ChecksumAlgorithm not working with presigned URL

Open petitout opened this issue 3 years ago • 2 comments

Documentation

Describe the bug

When creating a multipart upload with new field ChecksumAlgorithm specified, you can then create a presigned URL to upload a part. However, using the generated presigned URL always fails with

<Message>There were headers present in the request which were not signed</Message><HeadersNotSigned>x-amz-sdk-checksum-algorithm</HeadersNotSigned>

Expected Behavior

the generated URL should allow to upload a part without error

Current Behavior

using the presigned URL always fail with:

<Message>There were headers present in the request which were not signed</Message><HeadersNotSigned>x-amz-sdk-checksum-algorithm</HeadersNotSigned>

Reproduction Steps

...
   res, err := sThree.CreateMultipartUpload(context.Background(), &s3.CreateMultipartUploadInput{
		Bucket:            aws.String("mybucket"),
		Key:               aws.String("myobject"),
		ChecksumAlgorithm: types.ChecksumAlgorithmSha256,
	})
...
sha256 := ...
...
res2, err := s3Presign.PresignUploadPart(ctx, &s3.UploadPartInput{
		Bucket:            aws.String("mybucket"),
		Key:               aws.String("myobject"),
		UploadId:          res.UploadId,
		PartNumber:        1,
		ChecksumAlgorithm: types.ChecksumAlgorithmSha256,
		ChecksumSHA256:    &sha256,
	})

this generates an URL

use the URL :

curl -H "X-Amz-Sdk-Checksum-Algorithm: SHA256" URL --upload ./test.txt

response :

<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>AccessDenied</Code><Message>There were headers present in the request which were not signed</Message><HeadersNotSigned>x-amz-sdk-checksum-algorithm</HeadersNotSigned><RequestId>MPE5KZWW9QQQSA7Y</RequestId><HostId>LjOUkQwERD+hioCvfn7Keio6KZ3+CTI9NLN+OvlNrtBBT2nl22NW9wqmqfZtKDi9DhLlHpijFYE=</HostId></Error>

I tried without specifying the X-Amz-Sdk-Checksum-Algorithm and got this response :

<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>InvalidRequest</Code><Message>Checksum Type mismatch occurred, expected checksum Type: sha256, actual checksum Type: null</Message><RequestId>G3H1MH5AA9QZ86HM</RequestId><HostId>Qx7+NC2X3zTvHEQ0gcyjvuN6CbTzQVfyR3zGlDPxp96Vc4eqxcuoboCcFn/OWSDnA6ejCiDx2S8=</HostId></Error>

Possible Solution

No response

Additional Information/Context

No response

AWS Go SDK V2 Module Versions Used

github.com/aws/aws-sdk-go-v2 v1.16.4 github.com/aws/aws-sdk-go-v2/service/s3 v1.26.10

Compiler and Version used

go version go1.17.6 darwin/amd64

Operating System and version

Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:22 PDT 2022; root:xnu-8020.121.3~4/RELEASE_X86_64 x86_64

petitout avatar Jun 29 '22 17:06 petitout