From 00cd6a1e6eb15477b083c1ee06c86f7184d6b7f1 Mon Sep 17 00:00:00 2001 From: liangzai <2440983361@qq.com> Date: Tue, 2 Dec 2025 22:31:37 +0800 Subject: [PATCH] fix --- app/main/api/internal/config/config.go | 1 - .../api/internal/service/wechatpayService.go | 19 +++++-------------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/app/main/api/internal/config/config.go b/app/main/api/internal/config/config.go index 8479931..97aff3d 100644 --- a/app/main/api/internal/config/config.go +++ b/app/main/api/internal/config/config.go @@ -63,7 +63,6 @@ type WxpayConfig struct { MchPrivateKeyPath string MchPublicKeyID string MchPublicKeyPath string - MchPlatformRAS string // 微信支付平台证书序列号(用于回调验证) NotifyUrl string RefundNotifyUrl string } diff --git a/app/main/api/internal/service/wechatpayService.go b/app/main/api/internal/service/wechatpayService.go index d96e9f8..5d6dac4 100644 --- a/app/main/api/internal/service/wechatpayService.go +++ b/app/main/api/internal/service/wechatpayService.go @@ -137,22 +137,13 @@ func newWechatPayServiceWithWxPayPubKey(c config.Config, userAuthModel model.Use } // 初始化 notify.Handler - // 使用本地公钥直接验证,不依赖证书下载器(适用于2025年后新商户或平台证书过期的情况) - // SHA256WithRSACombinedVerifier 会先尝试从证书下载器获取证书,如果找不到且序列号匹配则使用本地公钥 - // 注意:回调通知中的序列号需要与 publicKeyID 匹配才能使用本地公钥 - // 如果配置了 MchPlatformRAS,使用它作为公钥ID(因为回调通知使用的序列号通常是平台证书序列号) - publicKeyIDForVerify := mchPublicKeyID - if c.Wxpay.MchPlatformRAS != "" { - // 如果配置了平台证书序列号,使用它作为验证时的公钥ID - // 这样回调通知中的序列号就能匹配上 - publicKeyIDForVerify = c.Wxpay.MchPlatformRAS - logx.Infof("使用平台证书序列号作为公钥ID进行回调验证: %s", publicKeyIDForVerify) - } - certificateVisitor := downloader.MgrInstance().GetCertificateVisitor(mchID) + // certificateVisitor := downloader.MgrInstance().GetCertificateVisitor(mchID) + // notifyHandler := notify.NewNotifyHandler( + // mchAPIv3Key, + // verifiers.NewSHA256WithRSACombinedVerifier(certificateVisitor, mchPublicKeyID, *mchPublicKey)) notifyHandler := notify.NewNotifyHandler( mchAPIv3Key, - verifiers.NewSHA256WithRSACombinedVerifier(certificateVisitor, publicKeyIDForVerify, *mchPublicKey)) - + verifiers.NewSHA256WithRSAPubkeyVerifier(mchPublicKeyID, *mchPublicKey)) logx.Infof("微信支付客户端初始化成功(微信支付公钥方式)") return &WechatPayService{ config: c,