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

Requests with no body don't sign correctly #567

Closed
lucix-aws opened this issue Mar 31, 2022 · 2 comments
Closed

Requests with no body don't sign correctly #567

lucix-aws opened this issue Mar 31, 2022 · 2 comments
Assignees
Labels
bug This issue is a bug.

Comments

@lucix-aws
Copy link
Contributor

Describe the bug

S3Client.createBucket, when called with only a bucket name as input, appears to be signing incorrectly. The service will reject the request claiming that the signature is invalid.

Expected behavior

Bucket should be created.

Current behavior

S3Exception is thrown: The request signature we calculated does not match the signature you provided. Check your key and signing method.

Steps to Reproduce

fun main():Unit = runBlocking {
    S3Client.fromEnvironment().use { s3 ->
        s3.createBucket { bucket = "buckettestdgttxcq" }

        s3.listBuckets {}.buckets?.forEach {
            println(it.name)
        }
    }
}

Possible Solution

No response

Context

No response

AWS Kotlin SDK version used

0.14.0-beta

Platform (JVM/JS/Native)

JVM

Operating System and version

macOS 12.2.1

@lucix-aws lucix-aws added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Mar 31, 2022
@ianbotsf ianbotsf removed the needs-triage This issue or PR still needs to be triaged. label Apr 1, 2022
@lucix-aws lucix-aws changed the title S3::createBucket doesn't sign correctly Requests with no body don't sign correctly Apr 4, 2022
@lucix-aws
Copy link
Contributor Author

This happens because we're setting Content-Type even when there's no body. We include that in the set of signed headers, but it looks like services do the calculation without it when the body is empty. So theoretically, any request with no body would fail in this way, not just this particular S3 API.

It appears to actually be a regression. We had previously set Content-Type conditionally - see https://github.com/awslabs/smithy-kotlin/pull/55/files# - but it looks like that code was dropped in later refactors.

@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug.
Projects
None yet
Development

No branches or pull requests

2 participants