无法在 Windows x86 上使用 Java 验证在 Linux x64 上签名的数字签名
我很难找到问题的原因。 问题的核心是 Signature.verify 总是返回 false。 在具有 x64 架构的 Linux 机器上创建签名,并在 Windows x86 上进行验证。
下面是用于签名的代码
Signature dsa = Signature.getInstance("SHA1withDSA");
dsa.initVerify(getPublicKey());
byte[] licenseeB = licensee.trim().toUpperCase().getBytes("UTF-8");
dsa.update(= merge(0, encodedLicenseB, licenseeB));
return dsa.verify(signature);
这是用于签名的代码
byte[] encodedLicenseB = license.getEncoded();
byte[] licenseeB = license.getLicensee().trim().toUpperCase().getBytes("UTF-8");
Signature dsa = Signature.getInstance("SHA1withDSA");
dsa.initSign(getPrivateKey());
dsa.update(merge(0, encodedLicenseB, licenseeB));
byte[] signature = dsa.sign();
从 IDE 进行签名和验证代码始终有效。没有出现任何异常。
请分享任何想法。
谢谢 !
I'm having hard time to find the reason of the problem.
The core of the problem is that Signature.verify always returns false.
Signature created on Linux box with x64 architecture and I verify on Windows x86.
Below is the code for signing
Signature dsa = Signature.getInstance("SHA1withDSA");
dsa.initVerify(getPublicKey());
byte[] licenseeB = licensee.trim().toUpperCase().getBytes("UTF-8");
dsa.update(= merge(0, encodedLicenseB, licenseeB));
return dsa.verify(signature);
This is code for signature
byte[] encodedLicenseB = license.getEncoded();
byte[] licenseeB = license.getLicensee().trim().toUpperCase().getBytes("UTF-8");
Signature dsa = Signature.getInstance("SHA1withDSA");
dsa.initSign(getPrivateKey());
dsa.update(merge(0, encodedLicenseB, licenseeB));
byte[] signature = dsa.sign();
Signing and verifying code on from IDE always works. No exceptions appears.
Please share any ideas.
Thanks !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论