0002-00000207

更新时间:
复制 MD 格式
Tip: To avoid constructing the Authorization header manually, use an Alibaba Cloud SDK, which handles V4 signature calculation automatically. See Overview.

Problem description

The Signature field is missing from the Authorization header in a V4 signature request.

Causes

The Authorization header for a V4 signature request must contain two required fields — Credential and Signature — plus the optional AdditionalHeaders field. The Signature field is absent.

The Authorization header has the following format:

{signature-version} {signature-information}
ComponentValue
Signature versionOSS4-HMAC-SHA256 (only supported value)
Signature informationKey-value pairs separated by commas (,), keys and values connected by equal signs (=)
FieldRequired
CredentialRequired
SignatureRequired
AdditionalHeadersOptional

Examples

The following request triggers this error because the Signature field is missing:

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
               ^^^^^^^^^^^^^^^^  signature version  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  Credential only — Signature field missing
x-oss-content-sha256: UNSIGNED-PAYLOAD

Solutions

Add the Signature field (and, if applicable, AdditionalHeaders) to the Authorization header:

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
               ^^^^^^^^^^^^^^^^  signature version                                           ^^^^^^^^^^^^^^^^^^^^  optional    ^^^^^^^^^^^^^^  required
x-oss-content-sha256: UNSIGNED-PAYLOAD

If the server returns a StringToSign parameter in the response, verify that your locally computed StringToSign matches the server's value before recalculating the signature.

References