0002-00000411

更新时间:
复制 MD 格式

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: true

Solutions

Set X-Amz-Algorithm to AWS4-HMAC-SHA256 and make sure all other signature parameters are valid.

ParameterRequired valueNotes
X-Amz-AlgorithmAWS4-HMAC-SHA256The only supported value
X-Amz-Credential<access-key-id>/<date>/<region>/s3/aws4_requestUse your OSS AccessKey ID
X-Amz-DateISO 8601 format, e.g., 20221220T084818ZMust match the request time
X-Amz-ExpiresSeconds until expiry, e.g., 86400
X-Amz-SignedHeadersHeaders included in the signature, e.g., host
X-Amz-SignatureThe 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: true

We 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.