微信请求头已添加Wechatpay-Serial,加密方法是从官方粘贴的:try {
Cipher cipher = Cipher.getInstance("RSA/ECB/OAEPWithSHA-1AndMGF1Padding");
cipher.init(Cipher.ENCRYPT_MODE, certificate.getPublicKey());
byte[] data = message.getBytes("utf-8");
byte[] cipherdata = cipher.doFinal(data);
return Base64.getEncoder().encodeToString(cipherdata);
}
catch (Exception e) {
log.error("", e);
return null;
},加密公钥使用的微信平台证书。接口调用报错:wechat pay server error, Request-ID 08B3ABD3B00610B80118A6FDCBF50120956928E0E201-269546542 , statusCode 400 BAD_REQUEST,result : {\"code\":\"PARAM_ERROR\",\"message\":\"平台私钥解密失败\"}。
这种一般是平台证书不正确或者加密方法不对,可以参考https://developers.weixin.qq.com/community/develop/doc/000eec863c8df887b0db292355b409