Open ciffelia opened 8 months ago
Thank you for the repro!
It looks like the assertion might have the wrong header name? It looks like it is in there:
[src/main.rs:22] presigned_request.headers().collect::<Vec<_>>() = [
(
"x-amz-sdk-checksum-algorithm",
"SHA256",
),
(
"x-amz-checksum-sha256",
"47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=",
),
]
Are you saying that S3 is failing to validate the checksum when using this presigned request?
Sorry, I typed the wrong header name. I corrected it, but the assertion still fails because the checksum value do not match. It should be "ungWv48Bz+pBQUDeXa4iI7ADYaOWF3qctBD/YfIAFa0="
, not "47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU="
.
yeah this seems like a bug—we're failing to detect the checksum is set already and we're recomputing it.
Seems related to #539 and #1085
I believe the issue is that you set the checksum algorithm as well as the sha256 checksum.
So with the following, it should work:
use std::time::Duration;
use aws_sdk_s3::{presigning::PresigningConfig, types::ChecksumAlgorithm};
#[tokio::main]
async fn main() {
let client = aws_sdk_s3::Client::new(&aws_config::load_from_env().await);
// checksum for b"abc"
let checksum = "ungWv48Bz+pBQUDeXa4iI7ADYaOWF3qctBD/YfIAFa0=";
let presigned_request = client
.put_object()
.bucket("example-bucket")
.key("foo")
.checksum_sha256(checksum)
.presigned(PresigningConfig::expires_in(Duration::from_secs(360)).unwrap())
.await
.unwrap();
dbg!(presigned_request.headers().collect::<Vec<_>>());
assert!(presigned_request
.headers()
.any(|(k, v)| { k == "x-amz-checksum-sha256" && v == checksum }));
}
Describe the bug
I am trying to create presigned URL for PutObject action using
aws-sdk-s3
crate. When I specify the value forx-amz-checksum-sha256
header usingchecksum_sha256
method, the specified checksum seems to be ignored.Expected Behavior
When I run the code above, the request header contains
("x-amz-checksum-sha256", "ungWv48Bz+pBQUDeXa4iI7ADYaOWF3qctBD/YfIAFa0=")
and the assertion passes.Current Behavior
The request header contains
("x-amz-checksum-sha256", "47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=")
and the assertion fails.47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=
is the checksum for empty data.https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=bf4910fbc283b478d9dd3d254f508392
Reproduction Steps
Full reproduction is available at the following repository.
https://github.com/ciffelia/aws-rust-sdk-repro-1
Possible Solution
No response
Additional Information/Context
No response
Version
Environment details (OS name and version, etc.)
Ubuntu 22.04 on WSL
Logs
No response