如何使用纯 Java 验证签名的 JAR?
我不想使用 jarsigner -verify
。 没有 JAR util 包可以解决我的问题吗? 我只想验证纯 Java 中的 JAR。
I don't want to use the jarsigner -verify
. Is there no JAR util package for my problem?
I just want to verfiy a JAR in pure Java.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
“jarsigner”只是验证 jar 的 java 程序的一个小包装。 在你的 JDK 中有一个“tools.jar”(通常是“C:\programs\Java\jdk1.6.0_13\lib\tools.jar”或类似的东西)。 在这个库中有一个类“JarSigner”,它提供了所需的功能。 只需将“tools.jar”放在类路径中即可!
的行为
下面是一个示例程序,用于演示import sun.security.tools.JarSigner;
输出为:
如果您需要更深入地了解签名过程,资源可用。
The "jarsigner" is just a small wrapper for a java program that verifies the jar. Inside your JDK there is a "tools.jar" (usally "C:\programs\Java\jdk1.6.0_13\lib\tools.jar" or something like this). Inside this library there is a class "JarSigner" that provides the desired ability. Just put the "tools.jar" on your classpath!
Heres an example program to demonstrate the behaviour
import sun.security.tools.JarSigner;
Output is:
The sources are availible if you need a deeper understanding of the signing process.