Issue description
The signature date in the Authorization header is invalid.
Cause
The request uses the V4 signature, but the signature date in the Credential field of the Authorization header is invalid.
Example
Sample request:
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/2022-12-20/cn-hangzhou/oss/aliyun_v4_request,Signature=18**0a
x-oss-content-sha256: UNSIGNED-PAYLOAD
The format of the Credential field is <AccessKeyId>/<SignDate>/<Region>/oss/aliyun_v4_request. In the format:
-
<AccessKeyId>: the AccessKey ID used to sign the request. -
<SignDate>: the signature date in theYYYYMMDDformat. For example,20221220for December 20, 2022. -
<Region>: the region in which the request accesses OSS resources.
In this example, <SignDate> is set to 2022-12-20, which is invalid.
Solution
Change <SignDate> to the YYYYMMDD format. In this example, use 20221220.
References
-
For information about how to use Alibaba Cloud SDKs to initiate a request that uses the V4 signature, see Overview.
-
Calculate the signature:
-
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.
If the server returns a response that contains the
StringToSignparameter, you must check whether the value of the StringToSign parameter on the server is the same as the string before calculation. -