Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why should I sign my JAR files?

Why should I sign my JAR files?

I know that I need to sign my client-side JAR files (containing Applets) so that special things like filesystem access can be done, and so that the annoying bit at the bottom of windows doesn't show, but why else? And do I need to sign my server-side JAR files containing Servlets, etc.?

Some basic rules for when and when not to sign JARs would be appreciated - thanks!

like image 285
Chris Carruthers Avatar asked Jun 09 '09 06:06

Chris Carruthers


People also ask

What is signing a jar file?

You use the JAR Signing and Verification Tool to sign JAR files and time stamp the signature. You invoke the JAR Signing and Verification Tool by using the jarsigner command, so we'll refer to it as "Jarsigner" for short. To sign a JAR file, you must first have a private key.

What is jar signing in java?

Jar signing is the process of applying a digital signature to a jar file so the receiver, using your public key, can verify its authenticity. Yes you can use it.

What are the benefits of a jar file?

The JAR File format provides the following benefits. By providing a digital signature in our JAR File, we enhance the security of Java files; as the authorized user who recognize our signature can access the files. It is easy to handle, create, maintain, update, etcetera. so the JAR tool is used to compress the size.

Can JAR files be malicious?

Although JAR malware is not a very common attack vector, it cannot be ignored. The cross-platform applicability of JAR malware can enable attackers to infiltrate organizations in multiple areas, with just a single piece of malware.


1 Answers

The short answer - don't, unless your company policy forces you to.

The long answer
Signing jars is effectively telling your customer "I made this, and I guarantee it won't mess up your system. If it does, come to me for retribution". This is why signed jars in client-side solution deployed from remote servers (applets / webstart) enjoy higher privileges than non-signed solutions do.

On server-side solutions, where you don't have to to placate the JVM security demands, this guarantee is only for your customer peace of mind.
The bad thing about signed jars is that they load slower than unsigned jars. How much slower? it's CPU-bound, but I've noticed more than a 100% increase in loading time. Also, patches are harder (you have to re-sign the jar), class-patches are impossible (all classes in a single package must have the same signature source) and splitting jars becomes a chore. Not to mention your build process is longer, and that proper certificates cost money (self-signed is next to useless).

So, unless your company policy forces you to, don't sign jars on the server side, and keep common jars in signed and non-signed versions (signed go to the client-side deployment, non-signed go to server-side codebase).

like image 95
Ran Biron Avatar answered Sep 24 '22 16:09

Ran Biron