-
Notifications
You must be signed in to change notification settings - Fork 248
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
Unable to specify SHA256 checksum when creating presigned URL for PutObject action in S3 #1103
Comments
Thank you for the repro! It looks like the assertion might have the wrong header name? It looks like it is in there:
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 |
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
The text was updated successfully, but these errors were encountered: