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 GMTSolutions
Set x-oss-expires to a valid Unix timestamp before signing. The following table lists all required query parameters for a V4 signature request.
| Parameter | Type | Description | Required |
|---|---|---|---|
x-oss-signature-verion | String | Signing algorithm identifier. Must be OSS4-HMAC-SHA256. | Yes |
x-oss-credential | String | Access key ID and credential scope (date, region, service, termination string). | Yes |
x-oss-expires | Unix timestamp | Expiration time of the signature. It is a Unix timestamp used to specify the validity period of the signature. | Yes |
x-oss-signature | String | The computed HMAC-SHA256 signature. | Yes |
x-oss-additional-headers | String | Extra 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 GMTIf the server returns a response that includes theStringToSignparameter, verify that theStringToSignvalue on the server matches the string before calculation.
References
For information about how to use Alibaba Cloud SDKs to initiate a request that uses the V4 signature, see Overview.
For information about how to calculate the V4 signature, see Calculate V4 signature by using OSS SDK for Python.
For information about how to specify the signature logic based on the V1 signature, see Overview.