From a2d97ae98fe403d7abff5cb54d3d95f3ae312c75 Mon Sep 17 00:00:00 2001 From: liushp Date: Mon, 27 Nov 2023 11:21:11 +0800 Subject: [PATCH] fix x-ca-timestamp validate (#653) --- plugins/wasm-cpp/extensions/hmac_auth/plugin.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/wasm-cpp/extensions/hmac_auth/plugin.cc b/plugins/wasm-cpp/extensions/hmac_auth/plugin.cc index 1c2fb1fb9..f3f2ddcb8 100644 --- a/plugins/wasm-cpp/extensions/hmac_auth/plugin.cc +++ b/plugins/wasm-cpp/extensions/hmac_auth/plugin.cc @@ -347,13 +347,13 @@ bool PluginRootContext::checkPlugin( deniedInvalidDate(); return false; } - time_offset = std::abs((long long)(timestamp - current_time)); // milliseconds to nanoseconds - time_offset *= 1e6; + timestamp *= 1e6; // seconds if (date.size() < MILLISEC_MIN_LENGTH) { - time_offset *= 1e3; + timestamp *= 1e3; } + time_offset = std::abs((long long)(timestamp - current_time)); } if (time_offset > rule.date_nano_offset) { LOG_DEBUG(absl::StrFormat("date expired, offset is: %u",