question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Presigned URL resolves in a SignatureDoesNotMatch

See original GitHub issue

Describe the issue

Hi, I have functionalities in our web application to upload and download a certain configuration file (xml). The upload works. But we want to enforce the download by using a presigned URL that is valid for 5 minutes.

When using that url we receive a SignatureDoesNotMatch. Screenshot 2020-11-20 at 11 00 09

Steps to Reproduce

Code to upload a configuration file:

public Boolean uploadConfiguration(Part file) throws IOException {
        String bucketName = System.getenv("AWS_BUCKET");
        PutObjectRequest request = PutObjectRequest.builder()
                .bucket(bucketName)
                .key("BeFirstConfiguration.xml")
                .build();
        PutObjectResponse response = s3Client.putObject(request, RequestBody.fromBytes(file.getInputStream().readAllBytes()));
        return StringUtils.isNotEmpty(response.eTag());
    }

Code to receive a presigned URL:

String bucketName = System.getenv("AWS_BUCKET");

        GetObjectRequest getUrlRequest = GetObjectRequest.builder()
                .bucket(bucketName)
                .key("BeFirstConfiguration.xml")
                .build();
        GetObjectPresignRequest getObjectPresignRequest = GetObjectPresignRequest.builder()
                .getObjectRequest(getUrlRequest)
                .signatureDuration(Duration.ofMinutes(10))
                .build();

        PresignedGetObjectRequest request = s3Presigner.presignGetObject(getObjectPresignRequest);

        log.info("Generating pre-signed URL.");
        return request.url().toString();

JavaConfig configuration

public S3Configuration s3Configuration() {
        return S3Configuration.builder().build();
    }

    @Bean
    public S3Presigner s3Presigner() {
        return S3Presigner.builder()
                .region(Region.EU_WEST_1)
                .serviceConfiguration(s3Configuration())
                .build();
    }

    @Bean
    public S3Client s3Client() {
        return S3Client.create();
    }

Current Behavior

After using that presigned url we get an SignatureDoesNotMatch.

Your Environment

  • AWS Java SDK version used: 2.15.31
  • JDK version used: openjdk:11 (docker image based on openjdk:11-jre-slim)
  • Operating System and version: Amazon Linux

Any ideas or help pls? Been stuck here for a while now.

kind regards

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:19 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
TVDSCcommented, Jan 6, 2021

hi @debora-ito I try to have a look this week and let you know. Thanks for this info!

kind regards

1reaction
duboisphcommented, Nov 23, 2020

Hmm, not sure whether we can help much. However there’s one thing I can think of:

Internally we use private VPC Endpoints for S3 (and DynamoDB). So maybe that’s conflicting. Can you specify which endpoint to use in your signing code?

For example with the AWS CLI that’s possible: aws s3 presign --endpoint-url https://s3.eu-west-1.amazonaws.com s3://MY_BUCKET_NAME/MY_FILE.pdf --region eu-west-1

Read more comments on GitHub >

github_iconTop Results From Across the Web

SignatureDoesNotMatch error when uploading to s3 via a pre ...
We were receiving the presigned url, but when tried to download the file with that presign url, it said "signature does not match"....
Read more >
S3 Signature Does Not Match Error When Using A Pre Signed ...
So I made my pre signed url using the AWS SDK: $cmd = $s3Client->getCommand('PutObject', array( 'Bucket' => $bucket, 'Key' => $key ...
Read more >
S3 SignatureDoesNotMatch error when using presigned ...
The first load of the content will render correctly but subsequent load will fail as Drupal will append &itok=123456 to AWS S3 presigned...
Read more >
luminous: presigned URL for PUT with metadata fails ...
Copied from rgw - Bug #23470: presigned URL for PUT with metadata fails: SignatureDoesNotMatch, Resolved, 03/27/2018 ...
Read more >
SignatureDoesNotMatch when calling AWS API from ... - ERROR
In this case the AWS S3 API URL was generated by some other ... To resolve this issue, one should add an HTTP...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found