Signature的verify方法抛出异常
jdk1.8环境下抛出异常(jdk1.6不会抛出异常)
Exception in thread "main" java.security.SignatureException: Signature length not correct: got 344 but was expecting 256
at sun.security.rsa.RSASignature.engineVerify(RSASignature.java:189)
at java.security.Signature$Delegate.engineVerify(Signature.java:1222)
at java.security.Signature.verify(Signature.java:655)
at SignUtil.verify(SignUtil.java:105)
at SignUtil.verify(SignUtil.java:51)
at DemoTestApplication.main(DemoTestApplication.java:26)
最终操作:
把签名的数据经过一次base64解码
Base64.getDecoder().decode(signedData)
网友评论