Skip to content

Commit

Permalink
fix x-ca-timestamp validate (alibaba#653)
Browse files Browse the repository at this point in the history
  • Loading branch information
liushp authored Nov 27, 2023
1 parent 324e0bc commit a2d97ae
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions plugins/wasm-cpp/extensions/hmac_auth/plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit a2d97ae

Please sign in to comment.