Merged
Conversation
根据微信官方API签名文档,待签名串格式应为: urlpath\nappid\ntimestamp\npostdata 原代码错误地在payload中包含了rsaKeySn,导致签名验证失败(40234错误)。 修复:从postWithSignature方法的签名payload中移除rsaKeySn字段。 新增:WxMaSignaturePayloadTest单元测试验证签名格式正确性。 Co-authored-by: binarywang <1343140+binarywang@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix invalid signature error for createstore API
Fix intracity API RSA signature error (errcode 40234)
Mar 10, 2026
🤖 Augment PR SummarySummary: 修复小程序同城配送等接口在启用服务端 API 签名时,因 RSA 待签名串多拼接了
🤖 Was this summary useful? React with 👍 or 👎 |
...n-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaSignaturePayloadTest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
本 PR 旨在修复微信小程序「服务端 API 签名」的待签名串(payload)拼接格式,使其符合官方文档要求,并尝试通过新增测试来解释/验证该格式。
Changes:
- 修复
postWithSignature的 RSA 签名 payload:移除将rsaKeySn拼入待签名串的逻辑 - 新增
WxMaSignaturePayloadTest,用于验证签名 payload 的换行拼接规则(含/不含rsaKeySn的差异)
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/BaseWxMaServiceImpl.java | 调整签名 payload 拼接格式,确保待签名串不再包含 rsaKeySn |
| weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaSignaturePayloadTest.java | 新增测试用例,尝试验证 payload 格式与签名验签结果的关系 |
...n-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaSignaturePayloadTest.java
Outdated
Show resolved
Hide resolved
Owner
|
@copilot apply changes based on the comments in this thread |
- 将 postWithSignature 中的 payload 拼接逻辑提取为包可见静态方法 buildSignaturePayload - 重写 WxMaSignaturePayloadTest,直接测试生产代码的 payload 格式 - 新测试断言:恰好4个字段、不含rsaKeySn、格式与官方规范完全一致 - 如果将来有人误将 rsaKeySn 加回 payload,测试将立即失败 Co-authored-by: binarywang <1343140+binarywang@users.noreply.github.com>
Contributor
Author
已按评审意见重构(commit 将 payload 拼接逻辑提取为包可见静态方法
若将来有人误将 |
Copilot
AI
changed the title
Fix intracity API RSA signature error (errcode 40234)
修复同城配送接口RSA签名错误(错误码40234)
Mar 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
postWithSignaturewas constructing the RSA signing payload with an extrarsaKeySnfield, causing WeChat to reject all intracity API calls with error 40234 (invalid signature).Per the WeChat API signature spec, the signing string must be exactly 4 fields:
Fix
rsaKeySnfrom the RSA signature payload inBaseWxMaServiceImpl#postWithSignature. The serial number is still correctly sent via theWechatmp-Serialrequest header.buildSignaturePayloadinBaseWxMaServiceImpl, enabling direct unit testing of the production logic.Tests
WxMaSignaturePayloadTest: directly callsBaseWxMaServiceImpl.buildSignaturePayloadand asserts:rsaKeySnIf
rsaKeySnis ever mistakenly added back to the payload, these tests will immediately fail, preventing regression.Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.