-
Notifications
You must be signed in to change notification settings - Fork 642
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
s3 client signature failure - with known good credentials #2069
Comments
Hi @dcopenhaver , Your code looks ok, I don't see any specific reason why you might run into a 403. Are you running this through a proxy, or from a context of a lambda or a container that might overwrite some headers? config.WithClientLogMode(aws.LogRequestWithBody|aws.LogResponseWithBody), Make sure you redact any sensitive information before sharing your logs. Thanks, |
Hi @RanVaknin, Thanks for the quick response. No proxy, direct connection from my dev machine to aws. Here is the httpClient:
I'll get the debug info shortly...
|
Hi @RanVaknin, Here's the extra logging info. I errored on the side of caution removing sensitive or potentially sensitive info:
I didn't include the response data that came after as I'm assuming what's already reported here is enough for that side, 403, and 'SignatureDoesNotMatch'. Let me know if there is something in there I should include though and I'll grab it. Thanks and Regards,
|
Hi @dcopenhaver , This is indeed odd. Your logs look good, your code looks correct, I'm able to run it successfully on my machine. With AWS support you will be assigned a person that will be able to reach out to any team in AWS. If you don't have access to support / can't do it, please let me know and I can file the internal ticket on your behalf. Thanks, |
Hi @RanVaknin, Ok, understood. I'm going to completely remove the involved components from my system and start a fresh module/project and retry. I'm thinking I should do this as I did do a lot 'go get', 'go get -u', on the original version of aws-sdk-go and then changing to aws-sdk-go-v2 after realizing that was available. So maybe I just made a mess of my local system during that process (though I did be sure to 'go mod tidy'). If it still fails I'll create the AWS ticket. Either way I'll update back here. Thanks for checking into this, much appreciated.
|
Hi @dcopenhaver , I think starting fresh is a good idea, however from the useragent string Im able to tell that you are using the correct version of the SDK. The only thing I can think of is that you are using some special characters in your bucket name that are not getting serialized correctly and causing a signatureMismatch error? At this point its all speculation. Please let me know if you are able to fix the issue or if you need help with anything else. |
The issue is resolved. It turned out to be something very unexpected and very much nothing to do with aws-sdk-go-v2. I was retrieving my aws credentials from the windows credential store which was storing the secretAccessKey part as UTF16 encoded bytes. So even though when I would fmt.Println(secretAccessKey) to verify my variable was holding the correct value it LOOKED right due to secretAccessKey=string(credBlob), whereas string() is smart enough, or the console also, to 'display' the string correctly but when I checked the output of secretAccessKey=="the hard coded secret" it came back FALSE! Converting the UTF16 to UTF8 was the fix for me. Thanks again for looking into this. I don't think I would have discovered that without knowing everything else looked fine and worked for you. Regards,
|
|
Describe the bug
operation error S3: PutObject, https response error StatusCode: 403, RequestID: REDACTED, HostID: REDACTED, api error SignatureDoesNotMatch: The request signature we calculated does not match the signature you provided. Check your key and signing method
Expected Behavior
successful putObject request
Current Behavior
operation error S3: PutObject, https response error StatusCode: 403, RequestID: REDACTED, HostID: REDACTED, api error SignatureDoesNotMatch: The request signature we calculated does not match the signature you provided. Check your key and signing method
Reproduction Steps
// the httpClient used simply changes the default timeout
ctx := context.Background()
cfg, err := config.LoadDefaultConfig(
ctx,
config.WithCredentialsProvider(credentials.NewStaticCredentialsProvider(accessKeyId, secretAccessKey, "")),
config.WithHTTPClient(httpClient),
config.WithRegion("us-east-1"),
)
if err != nil {
fmt.Printf("Error loading AWS SDK config.\n%v", err)
return
}
// create s3 service client
s3Client := s3.NewFromConfig(cfg)
// upload object to bucket
_, err = s3Client.PutObject(ctx, &s3.PutObjectInput{
Bucket: aws.String("theBucketName"),
Key: aws.String("theKeyName"),
Body: strings.NewReader("This is a test value"),
})
if err != nil {
fmt.Printf("ERROR occured during PutObject request:\n%v", err)
os.Exit(1)
}
Possible Solution
No response
Additional Information/Context
No response
AWS Go SDK V2 Module Versions Used
github.com/aws/aws-sdk-go-v2 v1.17.7
github.com/aws/aws-sdk-go-v2/config v1.18.19
github.com/aws/aws-sdk-go-v2/credentials v1.13.18
github.com/aws/aws-sdk-go-v2/service/s3 v1.31.0
Compiler and Version used
go1.19.4 windows/amd64
Operating System and version
Windows 11 Pro (10.0.22621 N/A Build 22621)
The text was updated successfully, but these errors were encountered: