Signing .Jar file

Stroes picture Stroes · Jun 19, 2013 · Viewed 18k times · Source

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.

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

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.

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.

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

Any help?

Thanks

Answer

Rajesh J Advani picture Rajesh J Advani · Jun 19, 2013

First create a key-pair using keytool.

keytool -genkey -alias somekeyname

Then use jarsigner to sign it with the key you just created.

jarsigner /path/to/jar somekeyname

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

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.

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").