From 7e7be46406988d96290084647cceb026f3108ee4 Mon Sep 17 00:00:00 2001 From: Marcus Watts Date: Wed, 10 Aug 2022 15:56:19 -0400 Subject: [PATCH] rgw: x-amz-date change breaks certain cases of aws sig v4. Once upon a time, x-amz-date strings were in rfc 2616 format, and most s3 clients are written to make this style of timestamp. The current protocol standard specifies iso 8601 timestamps (yyyymmddThhmmssZ), and client libraries are changing to use this new format. This change does two things: firstly, if the date parse fails, it logs the actual offending timestamp for later analysis. Secondly, if rfc 2616 fails, it tries iso 8601. The new timestamp is tried secondarily, because that lgoic also emits a (less useful) error message, which should not be spamnificated for valid rfc 2616 timestamps. Fixes: https://tracker.ceph.com/issues/57094 Signed-off-by: Marcus Watts (cherry picked from commit 70ba760f42766fe1075fc3f999e0393a2091b6e0) --- src/rgw/rgw_auth_s3.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/rgw/rgw_auth_s3.cc b/src/rgw/rgw_auth_s3.cc index 6fa6e651e50c..d8dc60f7e984 100644 --- a/src/rgw/rgw_auth_s3.cc +++ b/src/rgw/rgw_auth_s3.cc @@ -217,8 +217,9 @@ bool rgw_create_s3_canonical_header(const DoutPrefixProvider *dpp, if (header_time) { struct tm t; - if (!parse_rfc2616(req_date, &t)) { - ldpp_dout(dpp, 0) << "NOTICE: failed to parse date for auth header" << dendl; + uint32_t ns = 0; + if (!parse_rfc2616(req_date, &t) && !parse_iso8601(req_date, &t, &ns, false)) { + ldpp_dout(dpp, 0) << "NOTICE: failed to parse date <" << req_date << "> for auth header" << dendl; return false; } if (t.tm_year < 70) { -- 2.47.3