java 签署 .Jar 文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17187520/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-01 01:14:57  来源:igfitidea点击:

Signing .Jar file

appletcertificatejava

提问by Stroes

Im sitting with a bit of a problem. Im busy creating a php/html website (intranet) for our support team to make life a bit easier when support linux machines.

我坐着有点问题。我正忙于为我们的支持团队创建一个 php/html 网站(内联网),以便在支持 linux 机器时使生活更轻松。

I have a .jar app called mindterm (the free version) and want to run it as an applet in the site.

我有一个名为 mindterm(免费版本)的 .jar 应用程序,并希望将它作为站点中的小程序运行。

However according to their site you have to have the .jar file signed before loading it as an applet otherwise it cant open tcp connections.

但是,根据他们的网站,您必须在将 .jar 文件作为小程序加载之前对其进行签名,否则它无法打开 tcp 连接。

So i did as much research as i could in the time i had and came up with the jarsigner.exe and keytool.exe files provided in the JDK installation.

所以我在我有的时间里做了尽可能多的研究,并想出了 JDK 安装中提供的 jarsigner.exe 和 keytool.exe 文件。

However i do not have a clue how to go about signing this app so that i can actually use it.

但是,我不知道如何签署此应用程序以便我可以实际使用它。

Any help?

有什么帮助吗?

Thanks

谢谢

回答by Rajesh J Advani

First create a key-pair using keytool.

首先使用keytool.

keytool -genkey -alias somekeyname

Then use jarsignerto sign it with the key you just created.

然后使用jarsigner您刚刚创建的密钥对其进行签名。

jarsigner /path/to/jar somekeyname

Note, you need to use the same alias (somekeynamehere) as the one you create the key with.

请注意,您需要使用与somekeyname创建密钥相同的别名(此处)。

Now, since the certificate is self-signed, the user of your applet will be prompted to approve the certificate. Once they do so, your tcp connections should work.

现在,由于证书是自签名的,因此将提示您的小程序用户批准该证书。一旦他们这样做,您的 tcp 连接应该可以工作。

Since I assume you're only using the applet internally in your organization, self-signed certs should be fine. Otherwise you will have to pay for a certificate. In that case, your users will not need to accept the certificates after the first time (if they choose Always Allow").

由于我假设您仅在组织内部使用小程序,因此自签名证书应该没问题。否则,您将需要支付证书费用。在这种情况下,您的用户在第一次之后不需要接受证书(如果他们选择“始终允许”)。

回答by Makky

You can sign jars using :

您可以使用以下方法对 jar 进行签名:

Install this Eclipse plugin

安装这个 Eclipse 插件

Eclipse Webstart Plugin.

Eclipse Webstart 插件。

You will just need to export as "Webstart". It will prompt you to sign the jars.

您只需要导出为“Webstart”。它会提示您对罐子进行签名。

DEMO

演示

回答by Vadzim

Combined the top answer with someusefulhintsto get completely unattanded script:

将最佳答案与一些有用的提示相结合,以获得完全无人参与的脚本:

keytool -genkey -noprompt -alias Alias -dname "CN=Hostname, OU=OrganizationalUnit, O=Organization, L=City, S=State, C=Country" -keystore path.to.keystore -storepass password -keypass password -validity 3650
jarsigner -keystore path.to.keystore -storepass password -keypass password -signedjar signed.jar unsigned.jar Alias

回答by Thorbj?rn Ravn Andersen

This is a somewhat complex area, and you essentially need to know what you are doing, and you may have to pay real money for a signing certificate.

这是一个有点复杂的领域,您基本上需要知道自己在做什么,并且您可能需要为签名证书支付真钱。

The Sun Java Tutorial cover the topic well: http://docs.oracle.com/javase/tutorial/deployment/jar/signing.html

Sun Java 教程很好地涵盖了该主题:http: //docs.oracle.com/javase/tutorial/deployment/jar/signing.html

If the intent is to give the support people a ssh client, there might be better solutions.

如果目的是为支持人员提供 ssh 客户端,则可能有更好的解决方案。