javax.crypto.AEADBadTagException: Tag mismatch!
at com.sun.crypto.provider.GaloisCounterMode.decryptFinal(GaloisCounterMode.java:578)
at com.sun.crypto.provider.CipherCore.finalNoPadding(CipherCore.java:1116)
at com.sun.crypto.provider.CipherCore.fillOutputBuffer(CipherCore.java:1053)
at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:853)
at com.sun.crypto.provider.AESCipher.engineDoFinal(AESCipher.java:446)
at javax.crypto.Cipher.doFinal(Cipher.java:2164)
如题,按照官方的文档执行也是这样,所有参数都有了,包括APIv3秘钥,依然报错
调用的URL是:https://api.mch.weixin.qq.com/v3/certificates
解密代码:
private static String aesgcmDecrypt(String aad, String iv, String cipherText) throws Exception {
final Cipher cipher = Cipher.getInstance(ALGORITHM, "SunJCE");
SecretKeySpec key = new SecretKeySpec(AES_APIV3_KEY.getBytes(), "AES");
GCMParameterSpec spec = new GCMParameterSpec(TAG_LENGTH_BIT, iv.getBytes());
cipher.init(Cipher.DECRYPT_MODE, key, spec);
cipher.updateAAD(aad.getBytes());
return new String(cipher.doFinal(Base64.getDecoder().decode(cipherText)));
}
顶一个
自顶
你这个问题解决了吗?
你这个问题解决了吗? 有人管吗
https://wechatpay-api.gitbook.io/wechatpay-api-v3/chang-jian-wen-ti/qian-ming-xiang-guan