【问题标题】:Integrity check with S3 upload使用 S3 上传进行完整性检查
【发布时间】:2021-12-05 05:49:58
【问题描述】:

我正在尝试确保我上传到 S3 存储桶的文件在上传时不会被篡改。我正在尝试这个基于一个简单的例子,按照here列出的步骤。

据我了解,通读文档时,需要生成 md5 校验和,然后将其传递到 put 命令的 Content-MD5 标头中。以下是我采取的步骤,但无论如何都失败了。我在这里错过了什么?

openssl md5 -binary test-md5.txt | base64
Y7uGBT9hu26jZFre3slWqw==


aws s3api put-object --bucket cloudtrailmanual --key test-md5.txt --content-md5 Y7uGBT9hu26jZFre3slWqw==

An error occurred (BadDigest) when calling the PutObject operation (reached max retries: 4): The Content-MD5 you specified did not match what we received.

我尝试在不传递二进制标志的情况下生成 md5 校验和,对其进行 base64 编码,然后再次尝试,但同样失败。我在这里错过了什么?

【问题讨论】:

    标签: amazon-web-services amazon-s3 checksum


    【解决方案1】:

    这对我来说太愚蠢了,我错过了指定正文元素,默认情况下这是一个零字节的正文。

    这将按预期工作,将其发布给可能觉得这很方便的人。

    aws s3api put-object --bucket cloudtrailmanual --key test-md5.txt --content-md5 Y7uGBT9hu26jZFre3slWqw== --body test-md5.txt
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-01-10
      • 1970-01-01
      • 1970-01-01
      • 2012-12-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多