0002-00000204

更新时间:
复制 MD 格式

Problem description

The Authorization request header contains invalid signature information.

Causes

The request uses the V4 signature, but the Authorization header is malformed.

Examples

The following request fails because it includes an unknown key (UnknownKey=1) in the signature information:

GET /oss.jpg HTTP/1.1
Host: oss-example.oss-cn-hangzhou.aliyuncs.com
Date: Tue, 20 Dec 2022 08:48:18 GMT
Authorization: OSS4-HMAC-SHA256 CredentialAK**ID/20221220/us-east-1/oss/aliyun_v4_request,Signature=18**0a,UnknownKey=1
                                                                                                                    ^^^^^^^^^^^^^ invalid: unknown key
x-oss-content-sha256: UNSIGNED-PAYLOAD

The Authorization header for a V4 signature request has the following structure:

Authorization: <SignatureVersion> <SignatureInfo>
  • <SignatureVersion> and <SignatureInfo> are separated by a space.

  • <SignatureInfo> is a comma-separated list of key-value pairs, where each key and value are connected by an equal sign (=).

The valid signature information fields are:

FieldRequiredDescription
CredentialYesYour access key ID and the signing scope, in the format <AccessKeyID>/<Date>/<Region>/oss/aliyun_v4_request
AdditionalHeadersNoAdditional headers included in the signature
SignatureYesThe computed HMAC-SHA256 signature

Only OSS4-HMAC-SHA256 is supported as the signature version. Any key not listed in the table above is invalid.

Solutions

Fix the Authorization header to include only the required fields (Credential and Signature) and the optional field (AdditionalHeaders). Example:

GET /oss.jpg HTTP/1.1
Host: oss-example.oss-cn-hangzhou.aliyuncs.com
Date: Tue, 20 Dec 2022 08:48:18 GMT
Authorization: OSS4-HMAC-SHA256 Credential=AK**ID/20221220/us-east-1/oss/aliyun_v4_request,AdditionalHeaders=host,Signature=18**0a
x-oss-content-sha256: UNSIGNED-PAYLOAD

Verify the fix: If the server returns a response containing the StringToSign parameter, check that the StringToSign value on the server matches the string you computed before signing.

References