Skip to content

Commit 3ce22ad

Browse files
Force 'now' to be in UTC for signing requests (#1975)
Fix signing request during DST change
1 parent a41f58f commit 3ce22ad

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
### Fixed
2121

2222
- Buffer the response in temporary file to avoid issues when stream is used by another request's body
23+
- SignerV4: Fix signing request during DST change
2324

2425
## 1.27.1
2526

src/Signer/SignerV4.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function __construct(string $scopeName, string $region)
6262

6363
public function presign(Request $request, Credentials $credentials, RequestContext $context): void
6464
{
65-
$now = $context->getCurrentDate() ?? new \DateTimeImmutable();
65+
$now = $context->getCurrentDate() ?? new \DateTimeImmutable('now', new \DateTimeZone('UTC'));
6666

6767
// Signer date have to be UTC https://docs.aws.amazon.com/general/latest/gr/sigv4-date-handling.html
6868
$now = $now->setTimezone(new \DateTimeZone('UTC'));
@@ -73,7 +73,7 @@ public function presign(Request $request, Credentials $credentials, RequestConte
7373

7474
public function sign(Request $request, Credentials $credentials, RequestContext $context): void
7575
{
76-
$now = $context->getCurrentDate() ?? new \DateTimeImmutable();
76+
$now = $context->getCurrentDate() ?? new \DateTimeImmutable('now', new \DateTimeZone('UTC'));
7777

7878
// Signer date have to be UTC https://docs.aws.amazon.com/general/latest/gr/sigv4-date-handling.html
7979
$now = $now->setTimezone(new \DateTimeZone('UTC'));

0 commit comments

Comments
 (0)