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

The request signature we calculated does not match the signature you provided. #2229

Closed
kirankumar-mahi opened this issue Jul 11, 2017 · 7 comments
Assignees
Labels
api: storage Issues related to the Cloud Storage API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: question Request for information or clarification. Not an issue.

Comments

@kirankumar-mahi
Copy link

kirankumar-mahi commented Jul 11, 2017

Hi,

I am using latest aws-java-sdk-s3', version: '1.11.158'. I am getting SignatureDoesNotMatch error. I am using below code.

The request signature we calculated does not match the signature you provided. Check your Google secret key and signing method. com.amazonaws.services.s3.model.AmazonS3Exception: The request signature we calculated does not match the signature you provided. Check your Google secret key and signing method. (Service: Amazon S3; Status Code: 403; Error Code: SignatureDoesNotMatch; Request ID: null

    ClientConfiguration clientConfiguration = new ClientConfiguration();
    AWSCredentials awsCredentials = new BasicAWSCredentials("XXX","XXX");
    AmazonS3 amazonS3Client = AmazonS3ClientBuilder.standard().withCredentials(new  AWSStaticCredentialsProvider(awsCredentials)).withClientConfiguration(clientConfiguration)
            .withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration("https://storage.googleapis.com","Multi-Regional")).build();

    String keyName = UUID.randomUUID().toString();
    FileInputStream f = new FileInputStream(new File(filePath));
    TransferManager tx =  TransferManagerBuilder.standard().withS3Client(amazonS3Client).build();

    // Request server-side encryption.
    ObjectMetadata objectMetadata = new ObjectMetadata();
    objectMetadata.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION);
    objectMetadata.setContentType("application/octet-stream");

    tx.upload("XX", keyName, f,objectMetadata);
@frankyn
Copy link
Member

frankyn commented Jul 11, 2017

Hi @kirankumar-mahi!

Thanks for filing an issue! I'm trying to understand the context for your issue. What is your end goal for using aws-java-sdk-s3 with Google Cloud Storage?

@frankyn
Copy link
Member

frankyn commented Jul 11, 2017

I missed the last line in your script. IIUC, you're uploading a file to Google Cloud Storage using the aws-java-sdk-s3 client library and you're seeing the SignatureDoesNotMatch error?

@frankyn frankyn self-assigned this Jul 11, 2017
@vam-google vam-google added api: storage Issues related to the Cloud Storage API. type: question Request for information or clarification. Not an issue. priority: p2 Moderately-important priority. Fix may not be included in next release. labels Jul 11, 2017
@frankyn
Copy link
Member

frankyn commented Jul 11, 2017

@kirankumar-mahi, I was able to get passed this issue by using a different version of the signature (reference). I added the solution below, please let me know if you have any trouble. I tested this with version 1.11.158 and 1.11.160 for aws-java-sdk-s3.

  ClientConfiguration clientConfiguration = new ClientConfiguration();
  // Solution is update the Signer Version. 
  clientConfiguration.setSignerOverride("S3SignerType"); 

  AWSCredentials awsCredentials = new BasicAWSCredentials("XXX","XXX");
  AmazonS3 amazonS3Client = AmazonS3ClientBuilder.standard()
    .withCredentials(new  AWSStaticCredentialsProvider(awsCredentials))
    .withClientConfiguration(clientConfiguration)
    .withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration("https://storage.googleapis.com","Multi-Regional")).build();

  String bucketName = "bucket_name";
  String keyName = UUID.randomUUID().toString();
  String filePath = "path/to/file.ext";

  // I uploaded the file differently as `TransferManager` would hang after it completed
  amazonS3Client.putObject(new PutObjectRequest(bucketName, keyName, new File(filePath)));

@kirankumar-mahi
Copy link
Author

It got resolved. Thanks. Closing this

@gnanamalarvizhi
Copy link

gnanamalarvizhi commented Nov 11, 2017

@frankyn @kirankumar-mahi I have some issues with listObjects. Created new issue here

@allpereira
Copy link

@frankyn I found this same error in the version 1.11.602 of SDK.

@frankyn
Copy link
Member

frankyn commented Mar 2, 2020

Could you provide more context on the issue you're experiencing @allpereira?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the Cloud Storage API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

5 participants