0002-00000502

更新时间:
复制 MD 格式

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:

HeaderRequired formatFormat templateExample
DateGMT formatDDD, DD MMM YYYY HH:MM:SS GMTTue, 20 Dec 2022 08:48:18 GMT
x-oss-dateISO 8601 formatYYYYMMDD'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 GMT

Example 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: 20221220T084818Z

Solutions

Fix the header value to match the required format.

  • To fix the x-oss-date header, 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: 20221220T084818Z
  • To fix the Date header, 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
Note

Use Alibaba Cloud OSS SDKs to sign V4 requests. For details, see Overview.

References