feat(miniapp): 实现小程序加密网络通道服务端支持,修复 HMAC 签名与错误处理 Bug#3969
Draft
feat(miniapp): 实现小程序加密网络通道服务端支持,修复 HMAC 签名与错误处理 Bug#3969
Conversation
Open
Agent-Logs-Url: https://github.com/binarywang/WxJava/sessions/f3aba758-8b4a-479f-96bd-88ce00a9c176 Co-authored-by: binarywang <1343140+binarywang@users.noreply.github.com>
Agent-Logs-Url: https://github.com/binarywang/WxJava/sessions/f3aba758-8b4a-479f-96bd-88ce00a9c176 Co-authored-by: binarywang <1343140+binarywang@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add encrypted network channel for mini program
feat(miniapp): 实现小程序加密网络通道服务端支持,修复 HMAC 签名与错误处理 Bug
Apr 22, 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.
微信小程序加密网络通道(
getUserEncryptKey)API 已有基础实现,但存在签名计算错误、错误码判断缺陷,且缺少配套的 AES 加解密工具方法。Bug 修复
WxMaInternetServiceImplsha256()原先用sessionKey.getBytes(UTF_8)(base64 字符串的 UTF-8 字节)作为 HMAC key,应改为Base64.decodeBase64(sessionKey)(原始密钥字节),与微信其他加密 API 惯例一致errcode == -1仅捕获单一错误码且有 NPE 风险,改为errcode != null && errcode != 0新增功能
WxMaCryptUtils新增针对加密网络通道的 AES-128-CBC 工具方法,支持getUserEncryptKey返回的 Base64 编码 key 和 Hex 编码 iv:hexToBytes()内部辅助方法含输入校验(奇数长度、非法字符),非法输入抛出IllegalArgumentException。