{"record":{"id":"51b5ad1ee5a12f23","repo":"JeffreySu/WeiXinMPSDK","slug":"requestasync","errorCode":null,"errorMessage":"RequestAsync 签名验证失败：","messagePattern":"RequestAsync 签名验证失败：","errorType":"exception","errorClass":"TenpayApiRequestException","httpStatus":null,"severity":"critical","filePath":"src/Senparc.Weixin.TenPay/Senparc.Weixin.TenPayV3/HttpHandlers/TenPayApiRequest.cs","lineNumber":799,"sourceCode":"                                        var isTenpayPubKey =\n                                            TenPaySignHelper.IsPublicKey(\n                                                wechatpaySerial);\n                                        result.VerifySignSuccess =\n                                            TenPaySignHelper\n                                                .VerifyTenpaySign(\n                                                    _tenpayV3Setting\n                                                        .EncryptionType.Value,\n                                                    wechatpayTimestamp,\n                                                    wechatpayNonce,\n                                                    wechatpaySignatureBase64,\n                                                    content, pubKey,\n                                                    isTenpayPubKey);\n                                    }\n                                }\n                            }\n                            catch (Exception ex)\n                            {\n                                throw new TenpayApiRequestException(\"RequestAsync 签名验证失败：\" + ex.Message, ex);\n                            }\n                        }\n                    }\n                }\n                else\n                {\n                    result = createDefaultInstance?.Invoke() ?? GetInstance<T>(true);\n                    resultCode.Additional = content;\n                }\n                //T result = resultCode.Success ? (await responseMessage.Content.ReadAsStringAsync()).GetObject<T>() : new T();\n                result.ResultCode = resultCode;\n\n                return result;\n            }\n            catch (OperationCanceledException)\n            {\n                throw;\n            }","sourceCodeStart":781,"sourceCodeEnd":817,"githubUrl":"https://github.com/JeffreySu/WeiXinMPSDK/blob/be573f6f94bdbf718dd5f6cdecb137fbc7ff651e/src/Senparc.Weixin.TenPay/Senparc.Weixin.TenPayV3/HttpHandlers/TenPayApiRequest.cs#L781-L817","documentation":"The response signature verification block in RequestAsyncCore wraps its work in a try/catch and rethrows any failure (key load errors, signature mismatch, missing headers, key ID mismatch) as TenpayApiRequestException with the prefix 'RequestAsync 签名验证失败：' plus the inner exception message. It signals that WeChat Pay's response could not be authenticated.","triggerScenarios":"RequestAsync / RequestWithoutBodyAsync where signature verification throws: missing Wechatpay-* headers, serial not found among known platform certificates/public keys, malformed timestamp/nonce, or signature that doesn't verify against the platform key.","commonSituations":"Platform certificate not downloaded/refreshed (new serial introduced by WeChat rotation); brand key ID mismatch (see error 144); clock skew making timestamp validation fail; corrupted cached certificates.","solutions":["Read the InnerException message to identify the precise cause (unknown serial / bad signature / missing header).","Refresh the WeChat Pay platform certificates (call the certificates download API) so the response serial is known.","If using brand credentials, confirm WechatpayPublicKeyId matches the response serial exactly.","Ensure server clock is NTP-synced (timestamp validation is time-sensitive).","Catch TenpayApiRequestException in your code and fail safely rather than trusting unverified responses."],"exampleFix":"// before\nvar result = await apiRequest.RequestAsync<JObject>(url, json);\n// after\ntry\n{\n    var result = await apiRequest.RequestAsync<JObject>(url, json);\n}\ncatch (TenpayApiRequestException ex)\n{\n    logger.LogError(ex, \"WeChat Pay signature verification failed: {Inner}\", ex.InnerException?.Message);\n    throw; // do not process unverified responses\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try\n{\n    var result = await apiRequest.RequestAsync<TResponse>(url, json);\n}\ncatch (TenpayApiRequestException ex)\n{\n    logger.LogError(ex, \"WeChat Pay signature verification failed: {Inner}\", ex.InnerException?.Message);\n    throw; // fail closed on unverified responses\n}","preventionTips":["Periodically refresh WeChat Pay platform certificates so new serials verify.","Log InnerException messages — they pinpoint unknown-serial vs bad-signature causes.","Keep server time NTP-synced.","Treat verification failures as potential MITM and page on-call."],"tags":["signature-verification","security","weixin-pay"],"backgroundTag":"signature-verification-failed","analyzedSha":"be573f6f94bdbf718dd5f6cdecb137fbc7ff651e","analyzedAt":"2026-09-12T10:01:50.733Z","contentChangedAt":"2026-09-12T10:01:50.733Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}