|
@@ -28,6 +28,7 @@ import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.core.io.ClassPathResource;
|
|
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.Base64Utils;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
@@ -116,7 +117,7 @@ public class NotifyController {
|
|
|
String sign = request.getHeader("Wechatpay-Signature");
|
|
|
String timestamp = request.getHeader("Wechatpay-Timestamp");
|
|
|
String nonce = request.getHeader("Wechatpay-Nonce");
|
|
|
-
|
|
|
+ log.info("");
|
|
|
|
|
|
StringBuffer sb = new StringBuffer();
|
|
|
sb.append(timestamp + "\n");
|
|
@@ -128,12 +129,9 @@ public class NotifyController {
|
|
|
// 进行签名服务
|
|
|
Signature signature = Signature.getInstance("SHA256withRSA");
|
|
|
signature.initSign(privateKey);
|
|
|
- signature.update(sb.toString().getBytes("UTF-8"));
|
|
|
- byte[] signedData = signature.sign();
|
|
|
- String base64Str = Base64.getEncoder().encodeToString(signedData);
|
|
|
- log.info("签名串:"+base64Str);
|
|
|
- log.info("body读取串:"+sign);
|
|
|
- return sign.equals(base64Str);
|
|
|
+ Boolean result = signature.verify(Base64Utils.decodeFromString(sign));
|
|
|
+ log.info(result.toString());
|
|
|
+ return result;
|
|
|
|
|
|
}
|
|
|
|