Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.7.0 版本使用微信公钥 验签会报应答的微信支付签名验证失败 #3520

Open
tanglhui opened this issue Mar 4, 2025 · 6 comments

Comments

@tanglhui
Copy link

tanglhui commented Mar 4, 2025

提问前,请确保阅读过项目首页说明以及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
@yttBoy
Copy link

yttBoy commented Mar 7, 2025

请问解决了吗?

@SuchJack
Copy link

SuchJack commented Mar 7, 2025

同上,修复了吗

@tanglhui
Copy link
Author

tanglhui commented Mar 7, 2025 via email

@iready
Copy link

iready commented Mar 12, 2025

临时解决办法如下:

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);
            }
        };

@spacet1me
Copy link

请问一下,申请了公钥之后,本地调试报这个错,是需要点击开始转换公钥才能生效吗

@tanglhui
Copy link
Author

tanglhui commented Mar 18, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants