CertificatesManager certificatesManager = CertificatesManager.getInstance();
FileInputStream certKeyStream = new FileInputStream(new File(wxPayProperties.getCertKeyPath()));
FileInputStream weChatPayStream = new FileInputStream(new File(wxPayProperties.getWeChatPayPath()));
x509Certificate = PemUtil.loadCertificate(weChatPayStream);
privateKey = PemUtil.loadPrivateKey(certKeyStream);
certificatesManager.putMerchant(wxPayProperties.getMchId(), new WechatPay2Credentials(wxPayProperties.getMchId(), new PrivateKeySigner(wxPayProperties.getSerialNumber(), privateKey)), wxPayProperties.getApiV3Key().getBytes(StandardCharsets.UTF_8));
verifier = certificatesManager.getVerifier(wxPayProperties.getMchId());
使用上述方式获取平台证书,在接受到微信通知后,使用verifier进行验签,报商户证书为空。传的参数 mchid 商户id,secrialnumber 商户序列号
这段代码写在@PostConstruct 注解的方法内,只初始化一次,后面用成员变量使用
在使用微信SDK构建request的时候,商户证书号要填写微信回调传回来的公钥证书序列号,不要用自己私钥的证书序列号。
req.getHeader("wechatpay-serial")
NotificationRequest request = new NotificationRequest.Builder().withSerialNumber( req.getHeader("wechatpay-serial")) .withNonce(req.getHeader("wechatpay-nonce")) .withTimestamp(req.getHeader("wechatpay-timestamp")) .withSignature(req.getHeader("wechatpay-signature")) .withBody(body) .build();
String body = request.getReader().lines().collect(Collectors.joining(System.lineSeparator()))
请问怎么解决的
好兄die请问解决了么?
大家都有同样的问题,难道没人解决吗?
好兄弟,问题解决了,同样的问题
好兄弟,这个问题解决了吗?求解!
请问这个问题解决了吗