WxJava
WxJava copied to clipboard
4.7.0 版本使用微信公钥 验签会报应答的微信支付签名验证失败
提问前,请确保阅读过项目首页说明以及wiki开发文档相关内容,尤其是常见问题部分。完成内容后,请务必移除包括本句在内的无用内容,以免影响阅读,否则直接关闭,谢谢合作~
另外如果确认属于bug,而且已明确如何修复,请参考贡献指南直接提交PR,省的浪费时间在这里描述问题,非常感谢配合
简要描述
请简单概括描述下你所遇到的问题。
模块版本情况
- WxJava 模块名: 4.7.0
- WxJava 版本号:(旧版本不予支持,谢谢配合)
详细描述
尽量详细描述。请不要使用截图,尽量使用文字描述,代码直接贴上来,日志则请附在后面所示区域。
日志
如果日志不多,直接使用md代码引用格式贴在此处,否则如果太长,请将日志放在 pastebin 或者其他地方,然后将其url地址贴在这里
日志请写于此处
```com.github.binarywang.wxpay.exception.WxPayException: null
at com.github.binarywang.wxpay.service.impl.WxPayServiceApacheHttpImpl.postV3(WxPayServiceApacheHttpImpl.java:121)
at com.github.binarywang.wxpay.service.impl.BaseWxPayServiceImpl.unifiedOrderV3(BaseWxPayServiceImpl.java:780)
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:393)
at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:859)
at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1512)
at org.xnio.XnioWorker$WorkerThreadFactory$1$1.run(XnioWorker.java:1282)
at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: org.apache.http.client.ClientProtocolException: null
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:187)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108)
at com.github.binarywang.wxpay.service.impl.WxPayServiceApacheHttpImpl.postV3(WxPayServiceApacheHttpImpl.java:102)
... 77 common frames omitted
Caused by: org.apache.http.HttpException: 应答的微信支付签名验证失败
at com.github.binarywang.wxpay.v3.SignatureExec.executeWithSignature(SignatureExec.java:86)
at com.github.binarywang.wxpay.v3.SignatureExec.execute(SignatureExec.java:60)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
... 80 common frames omitted
请问解决了吗?
同上,修复了吗
要自己在postv3接口上加上请求头
---- 回复的原邮件 ---- | 发件人 | @.> | | 发送日期 | 2025年03月07日 15:37 | | 收件人 | binarywang/WxJava @.> | | 抄送人 | tanglhui @.>, Author @.> | | 主题 | Re: [binarywang/WxJava] 4.7.0 版本使用微信公钥 验签会报应答的微信支付签名验证失败 (Issue #3520) |
同上,修复了吗
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>
SuchJack left a comment (binarywang/WxJava#3520)
同上,修复了吗
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>
临时解决办法如下:
WxPayService wxPayService = new WxPayServiceImpl(){ private StringEntity createEntry(String requestStr) { return new StringEntity(requestStr, ContentType.create("application/json", "utf-8")); } @Override public String postV3(String url, String requestStr) throws WxPayException { HttpPost httpPost = new HttpPost(url); httpPost.setEntity(this.createEntry(requestStr)); httpPost.setConfig(RequestConfig.custom().setConnectionRequestTimeout(this.getConfig().getHttpConnectionTimeout()).setConnectTimeout(this.getConfig().getHttpConnectionTimeout()).setSocketTimeout(this.getConfig().getHttpTimeout()).build()); httpPost.addHeader("Accept", "application/json"); httpPost.addHeader("Content-Type", "application/json"); httpPost.addHeader("Wechatpay-Serial", publicKeyId); return postV3(url, httpPost); }
@Override
public String getV3(String url) throws WxPayException {
HttpGet httpGet = new HttpGet(url);
httpGet.addHeader("Accept", "application/json");
httpGet.addHeader("Content-Type", "application/json");
httpGet.addHeader("Wechatpay-Serial", publicKeyId);
return this.requestV3(url, httpGet);
}
};
请问一下,申请了公钥之后,本地调试报这个错,是需要点击开始转换公钥才能生效吗
是的
---- 回复的原邮件 ---- | 发件人 | @.> | | 发送日期 | 2025年03月18日 10:13 | | 收件人 | binarywang/WxJava @.> | | 抄送人 | tanglhui @.>, Author @.> | | 主题 | Re: [binarywang/WxJava] 4.7.0 版本使用微信公钥 验签会报应答的微信支付签名验证失败 (Issue #3520) |
请问一下,申请了公钥之后,本地调试报这个错,是需要点击开始转换公钥才能生效吗
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>
spacet1me left a comment (binarywang/WxJava#3520)
请问一下,申请了公钥之后,本地调试报这个错,是需要点击开始转换公钥才能生效吗
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>
这个错误好像是因为平台证书转公钥的过渡期,微信支付平台来自主选择返回内容是公钥还是平台证书。 我跟踪了下,在下图方法中,得到的证书ID其实是平台证书ID,所以验签就失败了。 看if中,貌似让请求满足if的条件可以跳过验证
请使用最新版