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

S3-CRT Client signature error on s3 object keys with special characters #2958

Closed
epasveer opened this issue May 14, 2024 · 5 comments
Closed
Labels
bug This issue is a bug. p3 This is a minor priority issue

Comments

@epasveer
Copy link

Describe the bug

When using the S3-CRT PUT command, this error is encountered if the object key contains a special character. In our case, the '@' character.

The regular S3 PUT command works as intended.

Expected Behavior

s3-crt client would work seamlessly against the same object keys that the regular s3 client supports.

Current Behavior

S3-crt client fails on object keys with special characters with the following message:

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

Reproduction Steps

Example code.

Change the bucket name. Make sure the object name has a '@' in the name.

#include <aws/core/Aws.h>
#include <aws/core/client/ClientConfiguration.h>

#include <aws/s3-crt/model/PutObjectRequest.h>
#include <aws/s3-crt/S3CrtClient.h>

#include <aws/s3/S3Client.h>
#include <aws/s3/model/PutObjectRequest.h>

int main(int argc, char ** argv) {

    // Init AWS API
    Aws::SDKOptions awsSdkOptions;
    awsSdkOptions.loggingOptions.logLevel = Aws::Utils::Logging::LogLevel::Trace;
    awsSdkOptions.httpOptions.installSigPipeHandler = true;
    Aws::InitAPI(awsSdkOptions);

    std::string bucket("your-bucket");
    std::string objectKey("scratch/objectwithspecialchar@");
    std::string region("us-east-1");
    std::string message("Hello, World!");

    // s3 client code: --> works
    {
        Aws::Client::ClientConfiguration config;
        config.region = region;

        Aws::S3::S3Client s3Client(config);

        Aws::S3::Model::PutObjectRequest objectRequest;
        objectRequest.WithBucket(bucket).WithKey(objectKey);

        const std::shared_ptr<Aws::IOStream> inputData = Aws::MakeShared<Aws::StringStream>("");
        *inputData << message.c_str();

        objectRequest.SetBody(inputData);

        auto putObjectOutcome = s3Client.PutObject(objectRequest);

        if (!putObjectOutcome.IsSuccess()) {
            std::cerr << "failed s3 client put: " << putObjectOutcome.GetError().GetMessage() << std::endl;
        } else {
            std::cerr << "s3 client success!" << std::endl;
        }
    }

    // s3-crt client code --> fails on signature verification
    {
        Aws::S3Crt::ClientConfiguration config;
        config.region = region;

        Aws::S3Crt::S3CrtClient s3Client(config);

        Aws::S3Crt::Model::PutObjectRequest objectRequest;
        objectRequest.WithBucket(bucket).WithKey(objectKey);

        const std::shared_ptr<Aws::IOStream> inputData = Aws::MakeShared<Aws::StringStream>("");
        *inputData << message.c_str();

        objectRequest.SetBody(inputData);

        auto putObjectOutcome = s3Client.PutObject(objectRequest);

        if (!putObjectOutcome.IsSuccess()) {
            std::cerr << "failed s3 CRT client put: " << putObjectOutcome.GetError().GetMessage() << std::endl;
        } else {
            std::cerr << "s3 CRT client success!" << std::endl;
        }
    }

    Aws::ShutdownAPI(awsSdkOptions);
}

Possible Solution

Possible resolution from #2898 ??

Additional Information/Context

No response

AWS CPP SDK version used

1.11.258

Compiler and Version used

gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-15)

Operating System and version

Rocky Linux 8.7 (Green Obsidian) x86_64

@epasveer epasveer added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels May 14, 2024
@DmitriyMusatkin
Copy link
Contributor

should have been fixed with #2898. can you try a more recent version?

@jmklix jmklix added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 2 days. p3 This is a minor priority issue and removed needs-triage This issue or PR still needs to be triaged. labels May 15, 2024
@epasveer
Copy link
Author

Sure. I'll try a newer release. I will update this task with the findings.

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 2 days. label May 16, 2024
@jmklix jmklix added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 2 days. label May 16, 2024
Copy link

Greetings! It looks like this issue hasn’t been active in longer than a week. We encourage you to check if this is still an issue in the latest release. Because it has been longer than a week since the last update on this, and in the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please feel free to provide a comment or add an upvote to prevent automatic closure, or if the issue is already closed, please feel free to open a new one.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label May 26, 2024
@epasveer
Copy link
Author

The latest "main" works fine. Thanks for the fix. This task can be closed.

@github-actions github-actions bot removed closing-soon This issue will automatically close in 4 days unless further comments are made. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 2 days. labels May 29, 2024
@jmklix jmklix closed this as completed May 29, 2024
Copy link

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

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. p3 This is a minor priority issue
Projects
None yet
Development

No branches or pull requests

3 participants