0002-00000216

更新时间:
复制 MD 格式

Problem description

A V4 signature request fails because x-oss-expires is present but has no value.

Causes

You initiate a request that uses the V4 signature. However, the x-oss-expires query parameter is empty.

Examples

In the following request, x-oss-expires= has no value, which causes the error:

GET /oss.jpg?x-oss-signature-verion=OSS4-HMAC-SHA256&x-oss-credential=***&x-oss-expires=&x-oss-additional-headers=host&x-oss-signature=8u**a3 HTTP/1.1
Host: oss-example.oss-cn-hangzhou.aliyuncs.com
Date: Tue, 20 Dec 2022 08:48:18 GMT

Solutions

Set x-oss-expires to a valid Unix timestamp before signing. The following table lists all required query parameters for a V4 signature request.

ParameterTypeDescriptionRequired
x-oss-signature-verionStringSigning algorithm identifier. Must be OSS4-HMAC-SHA256.Yes
x-oss-credentialStringAccess key ID and credential scope (date, region, service, termination string).Yes
x-oss-expiresUnix timestampExpiration time of the signature. It is a Unix timestamp used to specify the validity period of the signature.Yes
x-oss-signatureStringThe computed HMAC-SHA256 signature.Yes
x-oss-additional-headersStringExtra headers included in signing.No

The following corrected request sets x-oss-expires to a valid Unix timestamp:

GET /oss.jpg?x-oss-signature-verion=OSS4-HMAC-SHA256&x-oss-credential=LTAI****************/20221220/cn-hangzhou/oss/aliyun_v4_request&x-oss-expires=1141889120&x-oss-additional-headers=host&x-oss-signature=8u**a3 HTTP/1.1
Host: oss-example.oss-cn-hangzhou.aliyuncs.com
Date: Tue, 20 Dec 2022 08:48:18 GMT
If the server returns a response that includes the StringToSign parameter, verify that the StringToSign value on the server matches the string before calculation.

References