Problem description
The Date or x-oss-date header in the request uses an invalid format.
Causes
OSS enforces distinct format requirements for each header:
| Header | Required format | Format template | Example |
|---|---|---|---|
Date | GMT format | DDD, DD MMM YYYY HH:MM:SS GMT | Tue, 20 Dec 2022 08:48:18 GMT |
x-oss-date | ISO 8601 format | YYYYMMDD'T'HHMMSS'Z' | 20221220T084818Z |
Examples
The following examples show requests that use the V4 signature with incorrectly formatted headers.
Example 1 — Wrong format for `x-oss-date`
The x-oss-date header must use ISO 8601 format (YYYYMMDD'T'HHMMSS'Z'). The following request uses the GMT format instead, which is invalid for this header.
GET /oss.jpg?x-oss-signature-verion=OSS4-HMAC-SHA256&x-oss-credential=LTAI****************&x-oss-additional-headers=host&x-oss-signature=8u**** HTTP/1.1
Host: oss-example.oss-cn-hangzhou.aliyuncs.com
x-oss-date: Tue, 20 Dec 2022 08:48:18 GMTExample 2 — Wrong format for `Date`
The Date header must use GMT format. The following request uses the ISO 8601 format instead, which is invalid for this header.
GET /oss.jpg?x-oss-signature-verion=OSS4-HMAC-SHA256&x-oss-credential=LTAI****************&x-oss-additional-headers=host&x-oss-signature=8u**** HTTP/1.1
Host: oss-example.oss-cn-hangzhou.aliyuncs.com
Date: 20221220T084818ZSolutions
Fix the header value to match the required format.
To fix the
x-oss-dateheader, set its value to ISO 8601 format (YYYYMMDD'T'HHMMSS'Z'):GET /oss.jpg?x-oss-signature-verion=OSS4-HMAC-SHA256&x-oss-credential=LTAI****************&x-oss-additional-headers=host&x-oss-signature=8u**** HTTP/1.1 Host: oss-example.oss-cn-hangzhou.aliyuncs.com x-oss-date: 20221220T084818ZTo fix the
Dateheader, set its value to GMT format:GET /oss.jpg?x-oss-signature-verion=OSS4-HMAC-SHA256&x-oss-credential=LTAI****************&x-oss-additional-headers=host&x-oss-signature=8u**** HTTP/1.1 Host: oss-example.oss-cn-hangzhou.aliyuncs.com Date: Tue, 20 Dec 2022 08:48:18 GMT
Use Alibaba Cloud OSS SDKs to sign V4 requests. For details, see Overview.
References
For a V4 signature implementation example using the OSS SDK for Python, see Calculate V4 signature by using OSS SDK for Python.
For the V1 signature logic, see Overview.