mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-10-07 23:24:39 +08:00
🎨 #3530 【微信支付】修复未设置平台证书引起的v3请求构造异常
This commit is contained in:
@@ -347,10 +347,14 @@ public class WxPayConfig {
|
||||
}
|
||||
|
||||
private Verifier getVerifier(PrivateKey merchantPrivateKey, WxPayHttpProxy wxPayHttpProxy, PublicKey publicKey) {
|
||||
Verifier certificatesVerifier = new AutoUpdateCertificatesVerifier(
|
||||
new WxPayCredentials(mchId, new PrivateKeySigner(certSerialNo, merchantPrivateKey)),
|
||||
this.getApiV3Key().getBytes(StandardCharsets.UTF_8), this.getCertAutoUpdateTime(),
|
||||
this.getPayBaseUrl(), wxPayHttpProxy);
|
||||
Verifier certificatesVerifier = null;
|
||||
// 如果配置了平台证书,则初始化验证器以备v2版本接口验签(公钥灰度实现)
|
||||
if (this.getPrivateCertPath() != null && this.getPrivateKeyPath() != null) {
|
||||
certificatesVerifier = new AutoUpdateCertificatesVerifier(
|
||||
new WxPayCredentials(mchId, new PrivateKeySigner(certSerialNo, merchantPrivateKey)),
|
||||
this.getApiV3Key().getBytes(StandardCharsets.UTF_8), this.getCertAutoUpdateTime(),
|
||||
this.getPayBaseUrl(), wxPayHttpProxy);
|
||||
}
|
||||
if (publicKey != null) {
|
||||
Verifier publicCertificatesVerifier = new PublicCertificateVerifier(publicKey, publicKeyId);
|
||||
publicCertificatesVerifier.setOtherVerifier(certificatesVerifier);
|
||||
|
@@ -24,7 +24,7 @@ public class PublicCertificateVerifier implements Verifier{
|
||||
|
||||
@Override
|
||||
public boolean verify(String serialNumber, byte[] message, String signature) {
|
||||
if (!serialNumber.contains("PUB_KEY_ID")) {
|
||||
if (!serialNumber.contains("PUB_KEY_ID") && this.certificateVerifier != null) {
|
||||
return this.certificateVerifier.verify(serialNumber, message, signature);
|
||||
}
|
||||
try {
|
||||
|
Reference in New Issue
Block a user