【问题标题】:awscli, the request signature we calculated does not match the signature you providedawscli,我们计算的请求签名与您提供的签名不匹配
【发布时间】:2017-06-24 05:22:11
【问题描述】:

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

我收到以下错误(使用 sdk api、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.

【问题讨论】:

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


    【解决方案1】:

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

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

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

    【讨论】:

    • 我使用 aws configure 命令和 evn 变量(使用 SET VALUE=KEY),我可以列出存储桶的所有内容,但无法上传
    • 好的,看来您可能发现了一个缺陷!尝试进入 ~/.aws/config 并删除任何指定区域的内容,然后再次尝试运行命令。
    • 我测试过但没有解决方案,我使用的是windows操作系统,我会看看它是否与操作系统有关,因为它适用于ubuntu操作系统。谢谢你。
    • 如果您无法解决问题,请随时给我发送电子邮件至nicholas.lange[at]ibm.com,我们可以尝试解决。如果是缺陷,我想修复它,如果是操作系统问题,我想记录下来。
    • 谢谢@nick,最初我使用的是 windows,然后我使用了基于 docker ubuntu 图像的图像,我可以列出存储桶及其内容,但无法上传。现在我在 ubuntu os 14.04 和 python 2.7.6 上重做所有事情。这些都不适用于 aswcli(基于 python 的 cli)或代码。所以我转而使用 ruby​​ 代码和 ruby aws-sdk 对其进行测试,并且一切正常(上传/下载)。现在我很确定这与aws或boto提供的python版本有关。
    【解决方案2】:

    您收到错误的原因可能是签名版本不同。
    IBM Cloud Object Storage 使用签名版本 2,但默认版本是 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();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-18
      • 2021-10-15
      • 2014-02-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-23
      • 2017-12-20
      相关资源
      最近更新 更多