Problem description
The value of the X-Amz-Algorithm parameter in the request is invalid. OSS only accepts AWS4-HMAC-SHA256 for this parameter when processing Amazon S3-compatible V4 signature requests.
Causes
The X-Amz-Algorithm parameter specifies the signing algorithm for Amazon S3-compatible V4 signature requests. OSS supports only one value: AWS4-HMAC-SHA256, where AWS4 identifies Signature Version 4 and HMAC-SHA256 identifies the signing algorithm. Any other value, such as AWS4-HMAC-SHA1, causes this error.
Examples
The following request fails because X-Amz-Algorithm is set to AWS4-HMAC-SHA1, which OSS does not support:
GET /test.txt?X-Amz-Algorithm=AWS4-HMAC-SHA1&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-oss-s3-compat: trueSolutions
Set X-Amz-Algorithm to AWS4-HMAC-SHA256 and make sure all other signature parameters are valid.
| Parameter | Required value | Notes |
|---|---|---|
X-Amz-Algorithm | AWS4-HMAC-SHA256 | The only supported value |
X-Amz-Credential | <access-key-id>/<date>/<region>/s3/aws4_request | Use your OSS AccessKey ID |
X-Amz-Date | ISO 8601 format, e.g., 20221220T084818Z | Must match the request time |
X-Amz-Expires | Seconds until expiry, e.g., 86400 | |
X-Amz-SignedHeaders | Headers included in the signature, e.g., host | |
X-Amz-Signature | The calculated signature |
The following request uses the correct value:
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-oss-s3-compat: trueWe recommend using an Amazon S3 SDK to construct requests. SDKs handle signature generation automatically. For more information, see Use Amazon S3 SDKs to access OSS.