java - 签署我的 Jar 文件

标签 java jar digital-signature signing

我制作了一个 Java Swing GUI 并试图将其放到网站上,我将我的 html 文件放在 lwjgl_jar 文件夹中并解决了 my previous problem关于无法找到 AppletLoader 但我现在收到一个新错误:

Permissions for Applet Refused. Please accept the permissions dialogue to allow the applet to continue the loading process.

错误出现在告诉Java“这次运行”之后。所以我在网上搜索并发现我的问题的解决方案是我的 jar 文件尚未签名,考虑到我正在使用我认为应该已经签名的 Slick 和 lwjgl 文件,但我的 racegame.jar 包含我的,这很奇怪小程序可能需要签名,所以关注了this guide to signing jars :

然后进入最后一步并输入:jarsigner -keystore myKeystore racegame.jar myself 签署我的 racegame.jar 但它说:

jarsigner: unable to open jar file: racegame.jar

我尝试使用的任何其他 jar 文件也会出现此错误。

为什么不打开 jar 文件并对其进行签名?完全按照指南中显示的方式执行并测试了所有其他步骤。

最佳答案

我曾经在网上找到这篇关于 How to sign the JAR Files 的文章,这篇文章可能包含一些内容,可以在某种程度上帮助你。请看一看:

Sign All Applet JAR files

Applets are back! And now applets can do more than ever before thanks to 
signed JAR files. By signing your JARs, you can get access to the filesystem 
and other resources that were previously off-limits, provided the user 
grants your applet those privileges. And signing JAR files is now very easy 
thanks to tools bundled with the JDK. However, be certain to sign all JAR files 
used by your Java applet. If you sign the JAR file with your main applet class, 
your applet will launch. If it later uses classes from another JAR file, though, 
you can run into trouble. If the newly-loaded class tries a restricted operation 
and its JAR file isn't signed, your applet will fail at that point with a 
security exception. Rather than waiting for this and debugging it when it occurs, 
save yourself the trouble and sign all of your JAR files up front.

You can create your own certificate using tools provided by the JDK. 
keytool -genkey -alias mykey lets you create your own certificate. Be sure to 
specify an expiration date far in the future with -validity 1000. The default is 
only 6 months.

Sign your JAR files with jarsigner my.jar mykey (where my.jar is the name of 
the jar file to sign).

Deploy all of your JAR files to a folder on your web server, add an HTML page 
with the applet tag, and let the world enjoy your new applet with powerful 
permissions.

keytool -genkey -v -key store mycompany.keystore -alias myalias_goes_here -keyalg RSA -keysize 2048 -validity 10000

关于java - 签署我的 Jar 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14303644/

相关文章:

java - 如何在数字模式之间允许特定分隔符

java - 更新生产中的 Jar

macos - 漏洞?在 codesign --remove-signature 功能中

c++ - 加载 key 时 BER 解码错误

java - Tomcat 无法启动组件

Java 扫描器资源泄漏,.close() 不会因多次分配而关闭

Java 应用程序在运行 Spring Boot 时可以工作,但不能与 Apache 一起工作

java - .jar 导出不理解项目文件夹内的相对路径

java - 将 Eclipse 项目导出到 jar 时出现白窗口

c# - 撤销证书验证中的 X509RevocationMode.Online 问题