Problem description
The SignDate value in the x-oss-credential header uses an invalid date format.
Causes
V4 signature authentication requires SignDate in compact format (YYYYMMDD). The request uses a hyphenated format (YYYY-MM-DD), which OSS does not accept.
The x-oss-credential header must follow this format:
<AccessKeyId>/<SignDate>/<Region>/oss/aliyun_v4_requestSignDate must not contain hyphens. Use 20221220, not 2022-12-20.
Examples
The following request fails because SignDate is set to 2022-12-20 instead of 20221220:
GET /oss.jpg?x-oss-signature-verion=OSS4-HMAC-SHA256&x-oss-credential=LTAI****************/2022-12-20/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 GMTSolutions
Change SignDate from 2022-12-20 to 20221220:
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 contains the StringToSign parameter, verify that the StringToSign value on the server matches the string before calculation.
References
To send requests with V4 signatures using Alibaba Cloud SDKs, see Overview.
To calculate the V4 signature, see Calculate V4 signature by using OSS SDK for Python.
To use the V1 signature, see Overview.