wechatpay-java icon indicating copy to clipboard operation
wechatpay-java copied to clipboard

自动更新微信支付平台证书RSAAutoCertificateConfig 初始化报错

Open it-ll opened this issue 10 months ago • 2 comments

错误描述

@Bean("rsaAutoCertificateConfig")
    public RSAAutoCertificateConfig rsaAutoCertificateConfig() {
        String filePath = Objects.requireNonNull(getClass().getClassLoader().getResource(paymentConfigProperties.getWechatConfig().getPrivateKeyFromPath())).getFile();
        return new RSAAutoCertificateConfig.Builder()
                .merchantId(paymentConfigProperties.getWechatConfig().getMchId())
                .privateKeyFromPath(filePath)
                .merchantSerialNumber(paymentConfigProperties.getWechatConfig().getMerchantSerialNumber())
                .apiV3Key(paymentConfigProperties.getWechatConfig().getApiV3Key())
                .build();
    }

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.wechat.pay.java.core.RSAAutoCertificateConfig]: Factory method 'rsaAutoCertificateConfig' threw exception with message: Wrong HttpStatusCode[404] httpResponseBody[{"code":"RESOURCE_NOT_EXISTS","message":"无可用的平台证书,请在商户平台-API安全申请使用微信支付公钥。可查看指引https://pay.weixin.qq.com/docs/merchant/products/platform-certificate/wxp-pub-key-guide.html"}] HttpRequest[{"http_method":"GET","url":"https://api.mch.weixin.qq.com/v3/certificates?algorithm_type=RSA","uri":"https://api.mch.weixin.qq.com/v3/certificates?algorithm_type=RSA","headers":{"headers":{"Authorization":"WECHATPAY2-SHA256-RSA2048 mchid="1711388101",nonce_str="XKxFZBrnZDhaG3VdNQGCPzEaOJVu7Wut",timestamp="1742797106",serial_no="7645C3F1B407AA936A8B2DB25DFB8BEC24469C5E",signature="WW+JVwGCdhRYwJe+l3U9KplyJ4ULV/gY579Ol6vloTvpKkuotbw2UHIMDZX0zaLqQMuX7BqNcbABKbYT2eRsClulSd2Hl7zkANEOeWtQ9cRSBYIU8brr2oGBeBsR8rnaWHeSIYcoGKGqp5GPn4Go/cvFgUL4tkIQIfOV1HaFLOyZ7ruysDBSb1XAFjTq5e2nGoHJL0whE4Qddkjso60WSGEKFzQxM8WldSPQT++MB7Kwy9o5U+bprDHuFMg4fxPa5jCCRACseb1eR9slGwsISi9fxBRmDp+M1/QLSLJnCPBBtpBq0WR6xJiQMU9FpbWgl556a0N/NY6XITwEkqd2dw=="","Accept":" /","User-Agent":"WechatPay-Java/0.2.16 (Windows 11/10.0) Java/23.0.2 Credential/WechatPay2Credential Validator/ okhttp3/null","Content-Type":"application/json","Wechatpay-Serial":""}}}] at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:177) ~[spring-beans-6.1.6.jar:6.1.6] at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:644) ~[spring-beans-6.1.6.jar:6.1.6] ... 65 common frames omitted

重现bug的步骤

无可用的平台证书,请在商户平台-API安全申请使用微信支付公钥

预期行为

使用自动更新微信支付平台证书初始化时正常通过

导致错误的代码片段


操作系统

windows

Java 版本

17

wechatpay-java 版本

v0.2.16

其他信息

No response

it-ll avatar Mar 24 '25 06:03 it-ll

同样问题,换成加载本地证书就可以了

Im-SAMW avatar Mar 27 '25 01:03 Im-SAMW

同样问题,换成加载本地证书就可以了

我换了公私钥的方式,平台证书得先去获取

it-ll avatar May 06 '25 10:05 it-ll