Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The request signature we calculated does not match the signature you provided. Check your key and signing method. #1252

Closed
nextdimension opened this issue May 5, 2017 · 7 comments
Labels
service-api This issue is due to a problem in a service API, not the SDK implementation.

Comments

@nextdimension
Copy link

nextdimension commented May 5, 2017

Version of AWS SDK for Go?

Latest

Version of Go (go version)?

go version go1.8 linux/amd64

What issue did you see?

When creating a PutObjectRequest like below it works fine I can PUT the file no problem. When I add
ACL: aws.String("public-read"), I get the error in the title, here is a sample of the url the GO sdk is generating.

https://<MY-BUCKET>.s3.eu-west-2.amazonaws.com/<MY-KEY>?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=<AWS_ACCESS_KEY>/20170505/eu-west-2/s3/aws4_request&X-Amz-Date=20170505T793528Z&X-Amz-Expires=900&X-Amz-SignedHeaders=host;x-amz-acl&X-Amz-Signature=2584062aaa76545665bfed7204fcf0dfe233a45016f698e7e8a11c34a5a7921e

I have tried with the root aws user and a normal user.
I have tried with bucket policy and without, and with bucket policy and IAM policy of FULL S3 access and without. Basically all combinations. Any time I add the ACL field the signature error appears.

I do not think that the url is being generated properly.

svc := s3.New(session.New(&aws.Config{Region: aws.String("eu-west-2")}))
	req, _ := svc.PutObjectRequest(&s3.PutObjectInput{
		ACL: aws.String("public-read"),
		Bucket: aws.String("MY BUCKET NAME"),
		Key:    aws.String("MY KEY"),
	})
	str, err := req.Presign(15 * time.Minute)
@xibz
Copy link
Contributor

xibz commented May 5, 2017

Hello @nextdimension, thank you for reaching out to us. It looks like the Acl header is not being signed on the service's end. I am going to reach out to the service team and see why that is.

@xibz xibz added the service-api This issue is due to a problem in a service API, not the SDK implementation. label May 5, 2017
@nextdimension
Copy link
Author

Oh, thank godness, theres an answer! I was going out of my mind :D Thanks.

@xibz
Copy link
Contributor

xibz commented May 16, 2017

@nextdimension - It looks like you have to set the header explicitly in the request.

package main                                                                                                               
                                                                                                                           
import (                                                                                                                   
  "fmt"                                                                                                                    
  "net/http"                                                                                                               
  "time"                                                                                                                   
                                                                                                                           
  "github.com/aws/aws-sdk-go/aws"                                                                                          
  "github.com/aws/aws-sdk-go/aws/session"                                                                                  
  "github.com/aws/aws-sdk-go/service/s3"                                                                                   
)                                                                                                                          
                                                                                                                           
func main() {                                                                                                              
  svc := s3.New(session.New(&aws.Config{Region: aws.String("eu-west-2")}))                                                 
  req, _ := svc.PutObjectRequest(&s3.PutObjectInput{                                                                       
    ACL:    aws.String("public-read"),                                                                                     
    Bucket: aws.String("BUCKET"),                                                                                   
    Key:    aws.String("MY KEY"),                                                                                          
  })                                                                                                                       
                                                                                                                           
  str, headers, _ := req.PresignRequest(15 * time.Minute)                                                                  
  httpreq, _ := http.NewRequest("PUT", str, nil)                                                                           
  for k, values := range headers {                                                                                         
    for _, value := range values {                                                                                         
      httpreq.Header.Add(k, value)                                                                                         
    }                                                                                                                      
  }                                                                                                                        
  fmt.Println(http.DefaultClient.Do(httpreq))                                                                              
}

If you have any additional issues, please let us know!

@xibz
Copy link
Contributor

xibz commented May 16, 2017

I am going to go ahead and close this issue. If you are still having issues, please reopen this.

@brydavis
Copy link

@xibz
I used your final code snippet and am receiving a 403 Forbidden.
Any ideas?

@edpark11
Copy link

Adding the headers worked for me. Thanks!

@brydavis
Copy link

Figured it out... although I didn't need the 'public-read' ACL argument.

Needed to add non-zero httpreq.ContentLength for file.

skotambkar pushed a commit to skotambkar/aws-sdk-go that referenced this issue May 20, 2021
Updates smithy Gradle dependency to v0.5.3.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
service-api This issue is due to a problem in a service API, not the SDK implementation.
Projects
None yet
Development

No branches or pull requests

4 participants