Problem description
The value of the X-Amz-Content-SHA256 request header is invalid.
Causes
You initiated a request using the Amazon S3-compatible AWS Signature Version 4, but the X-Amz-Content-SHA256 header contains an invalid value.
The valid values depend on the HTTP method:
| HTTP method | Required value for X-Amz-Content-SHA256 |
|---|---|
| GET, HEAD, DELETE, and other non-body methods | SHA-256 hash of an empty string, or the literal string UNSIGNED-PAYLOAD |
| POST and PUT | SHA-256 hash of the request body |
Examples
The following request fails because GET is used but X-Amz-Content-SHA256 is set to an arbitrary value (ab***123) instead of UNSIGNED-PAYLOAD:
GET /test.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=LTAI****************/20221220/us-east-1/s3/aws4_request&X-Amz-Date=20221220T084818Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=ab2***st HTTP/1.0
Date: Tue, 20 Dec 2022 08:48:18 GMT
Host: oss-example.oss-cn-hangzhou.aliyuncs.com
X-Amz-Content-SHA256: ab***123
x-oss-s3-compat: trueSolutions
Set X-Amz-Content-SHA256 to UNSIGNED-PAYLOAD and verify that all query parameters in the URL are present and contain valid values:
GET /test.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=LTAI****************/20221220/us-east-1/s3/aws4_request&X-Amz-Date=20221220T084818Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=ab2s**** HTTP/1.0
Date: Tue, 20 Dec 2022 08:48:18 GMT
Host: oss-example.oss-cn-hangzhou.aliyuncs.com
X-Amz-Content-SHA256: UNSIGNED-PAYLOAD
x-oss-s3-compat: trueWe recommend that you use Amazon S3 SDKs to initiate the request. For more information, see Use Amazon S3 SDKs to access OSS.
该文章对您有帮助吗?