Skip to content

Commit 75beb32

Browse files
committed
Long.ParseLong(timestamp); 拒绝5分钟之外的应答
1 parent e63efac commit 75beb32

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/main/java/com/wechat/pay/contrib/apache/httpclient/auth/WechatPay2Validator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ protected final void validateParameters(CloseableHttpResponse response) {
7373
} else {
7474
Header timestamp = response.getFirstHeader("Wechatpay-Timestamp");
7575
try {
76-
Instant instant = Instant.ofEpochSecond(Integer.parseInt(timestamp.getValue()));
77-
// 拒绝5分钟之前的应答
78-
if (Duration.between(instant, Instant.now()).toMinutes() >= 5) {
76+
Instant instant = Instant.ofEpochSecond(Long.parseLong(timestamp.getValue()));
77+
// 拒绝5分钟之外的应答
78+
if (Duration.between(instant, Instant.now()).abs().toMinutes() >= 5) {
7979
throw parameterError("timestamp=[%s] expires, request-id=[%s]",
8080
timestamp.getValue(), requestId);
8181
}

0 commit comments

Comments
 (0)