awscli,我们计算的请求签名与您提供的签名不匹配

时间:2017-01-13 15:11:22

标签: ibm-cloud-infrastructure aws-cli boto3 object-storage

我使用awscli(S3 Api)通过我的softlayer objectstorage操作一些请求。我可以检索存储桶列表,创建或删除存储桶。 当我尝试将示例文件复制到特定存储桶时,我收到错误: aws --endpoint-url=https://s3-api.us-geo.objectstorage.softlayer.net s3 cp test.txt s3://my_test_bucket/files

我收到以下错误(使用sdk apis,python boto3 api和wascli进行测试)

upload failed: ./test.txt to s3://my_test_bucket/test.txt An error occurred (SignatureDoesNotMatch) when calling the PutObject operation: The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. For more information, see REST Authentication and SOAP Authentication for details.

2 个答案:

答案 0 :(得分:1)

这很奇怪 - 您似乎使用了正确的语法。你是如何通过证件的?最简单的方法是在~/.aws/credentials文件中包含:

[default]
aws_access_key_id = {Access Key ID}
aws_secret_access_key = {Secret Access Key}

如果您在不同的工具/库中遇到相同的错误,则可能是这个问题。如果您正确设置了凭据并且仍然遇到签名问题,我们可能需要更深入地了解发生了什么,因为看起来您没有做错任何事情。

答案 1 :(得分:0)

您收到错误的原因可能是签名版本不同。
使用签名版本2的IBM Cloud Object Storage,但默认版本为4。 http://docs.aws.amazon.com/general/latest/gr/signature-version-2.html

我不确定如何通过curl和python设置签名版本 在SDK for Java中,您需要像这样设置,否则您会收到错误。

AWSCredentialsProvider provider = loadCredentialProvider();

ClientConfiguration config = new ClientConfiguration();
config.withSignerOverride("S3SignerType");

// second arg region not needed
EndpointConfiguration endpointConfiguration = 
        new EndpointConfiguration(us-geo.objectstorage.softlayer.net, "");

AmazonS3 cos = AmazonS3ClientBuilder.standard()
        .withCredentials(provider)
        .withClientConfiguration(config)
        .withEndpointConfiguration(endpointConfiguration)
        .build();
相关问题