Skip to content

S3 upload fails after enabling FIPS in OpenSSL #3198

Open
@parsley72

Description

@parsley72

Describe the bug

We've had the SDK working with our app fine, but we've recently added FIPS support to OpenSSL. When we run our app uploads to S3 failed.

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

We expect the S3 upload to work as before.

Current Behavior

Uploads to S3 fail with the error:
InvalidDigest, Unable to parse
ExceptionName: InvalidDigest Message: The Content-MD5 you specified was invalid.

Reproduction Steps

Our code looks like this:

bool upload_image_to_s3(const char* bucket_name, const char* source_file_name, const char* s3_name) {
       Aws::S3::Model::PutObjectRequest object_request;
        const std::shared_ptr<Aws::IOStream> input_data = Aws::MakeShared<Aws::FStream>(
            "PutObjectInputStream", source_file_name, std::ios_base::in | std::ios_base::binary);
        object_request.SetBucket(bucket_name);
        object_request.SetKey(s3_name);
        object_request.SetContentType("image/jpeg");
        object_request.SetBody(input_data);

        auto put_object_outcome = _pS3Client->PutObject(object_request);
        if (!put_object_outcome.IsSuccess()) {
            auto error = put_object_outcome.GetError();
            lgr_warn("MotorolaWebRequests::upload_image_to_s3: false. %s, %s", error.GetExceptionName().c_str(),
                error.GetMessage().c_str());
            return false;
        }

Possible Solution

We fixed this in our app by calculating the MD5 ourselves then adding it to the PutObjectRequest:

        std::string strMyMD5;
        dfcCalcHashMD5File_Base64(source_file_name, strMyMD5);
        object_request.SetContentMD5(strMyMD5);

Additional Information/Context

No response

AWS CPP SDK version used

1.11.404

Compiler and Version used

gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0

Operating System and version

Ubuntu 22

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.p3This is a minor priority issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions