【问题标题】:How to calculate md5-content header in unix shell?如何在 unix shell 中计算 md5-content 标头?
【发布时间】:2018-10-12 22:09:32
【问题描述】:

我正在寻找用于计算要与 IBM Cloud Object Storage API 一起使用以删除多个对象的 md5-content 标头的 unix 命令。我试过echo “request body….” | md5 | base64,但是 API 响应是 - `

您指定的 Content-MD5 无效。

卷曲命令:

curl -H "Content-Type: text/plain;charset=utf-8" -H "Content-MD5: 75ff06f81643655397a5911ddc195ce8" -H "Authorization: $AuthToken"  "https://<cos-endpoint-name>/<bucket-name>?delete" -d 'xml body...'

错误响应:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Error><Code>InvalidDigest</Code><Message>The Content-MD5 you specified was an invalid.</Message><Resource>/ghhsa-bucket-etl-dev/</Resource><RequestId>aed25243-22a1-477d-9ab8-b87780625a61</RequestId><httpStatusCode>400</httpStatusCode></Error>

感谢任何关于此的指针。

【问题讨论】:

    标签: object-storage ibm-cloud-storage


    【解决方案1】:

    md5 内置函数有点弱,如果可能的话,使用openssl 进行加密会更简单一些。使用文档中的示例:

    echo -n '<?xml version="1.0" encoding="UTF-8"?><Delete><Object><Key>pasture/cow-one</Key></Object><Object><Key>pasture/cow-two</Key></Object></Delete>' | openssl dgst -md5 -binary | openssl enc -base64
    

    这将返回 /Gx4aOgplRXMRI2qXXqXiQ==,这是我们所期望的。

    【讨论】:

      猜你喜欢
      • 2013-09-08
      • 1970-01-01
      • 2021-01-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-22
      • 2018-12-12
      • 1970-01-01
      相关资源
      最近更新 更多