需要验证 JAR 文件的完整性吗?

发布于 2024-08-04 16:03:29 字数 221 浏览 3 评论 0原文

我有一个 zip 文件,其中包含许多从 HTTPS 站点下载的 jar 文件。

这些 jar 形成了命令行驱动的服务器端应用程序。我有一个 Java 编写的应用程序安装程序,它会执行一些检查来验证 jar 是否使用特定的受信任数字证书进行签名,并且在传输过程中没有被修改。

是否有必要在收到 jar 文件时验证它,或者这是 JVM 所做的事情?我知道 JVM 会验证字节码,但是 jar 签名呢?

I have a zip file containing a number of jar files that is being downloaded from an HTTPS site.

The jars form a command line driven, server side application. I have a Java written application installer that does some checks to verify that the jars are signed using a particular trusted digital certificate and have not been modified during their transport.

Is it it necessary to verify the jar files upon receipt, or is this something the JVM does anyway? I know the JVM verifies the byte code, but what about jar signing?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

飘然心甜 2024-08-11 16:03:29

这取决于罐子的使用方式。

如果 jar 最终由类加载器加载,则类加载器可能会执行签名验证。如果类加载器恰好是 URLClassLoader,然后它将执行签名验证。

如果您使用 JarFile 类在 Java API 中访问 JAR,然后使用接受 String 或 File 参数的简单构造函数将导致执行验证。如果需要,必须明确关闭验证。

It depends on how the jars are being used.

If the jars are eventually loaded by a classloader, the classloader might perform verification of the signature. If the classloader happens to be an instance of URLClassLoader, then it will perform verification of the signature.

If you utilize the JarFile class in the Java API to access the JARs, then using the simple constructors that accept String or File arguments will result result in verification being performed. One must explicitly switch off verification, if needed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文