微信支付 V3 支付成功 应答验签失败?
小程序使用V3版本的微信支付调用成功,收到服务器的应答,通过微信SDK 0.2.1版本获取到微信平台证书并且与应答中的证书编号比较是一致的,接下来按文档说明进行验签,一直验签失败,实在找不出原因了,以下是我的代码 AutoUpdateCertificatesVerifier verifier = new AutoUpdateCertificatesVerifier( new WechatPay2Credentials(this.wxPayManager.getMchId(), new PrivateKeySigner( this.wxPayManager.getSerialNo(), this.wxPayManager.getPrivateKey())), this.wxPayManager.getKey().getBytes("utf-8")); String Timestamp = request.getHeader("Wechatpay-Timestamp"); logger.info("Wechatpay-Timestamp=" + Timestamp); // 应答随机串 String Nonce = request.getHeader("Wechatpay-Nonce"); logger.info("Wechatpay-Nonce=" + Nonce); // 应答签名 String SignatureText = request .getHeader("Wechatpay-Signature"); logger.info("Wechatpay-Signature=" + SignatureText); //buffer为接收到的JSON格式应答内容 String text = Timestamp + "\n" + Nonce + "\n" + buffer.toString() + "\n"; logger.info("text=" + text); Signature sign = Signature.getInstance("SHA256withRSA"); sign.initVerify(verifier.getValidCertificate() .getPublicKey()); sign.update(text.getBytes()); boolean verify = sign.verify(Base64.getDecoder().decode(SignatureText.getBytes()));