Questions tagged [jarsigner]

jarsigner - JAR Signing and Verification Tool Generates signatures for Java ARchive (JAR) files, and verifies the signatures of signed JAR files.

The jarsigner tool is used for two purposes:

  1. to sign Java ARchive (JAR) files, and
  2. to verify the signatures and integrity of signed JAR files.

The JAR feature enables the packaging of class files, images, sounds, and other digital data in a single file for faster and easier distribution. A tool named jar enables developers to produce JAR files. (Technically, any zip file can also be considered a JAR file, although when created by jar or processed by jarsigner, JAR files also contain a META-INF/MANIFEST.MF file.)

A digital signature is a string of bits that is computed from some data (the data being "signed") and the private key of an entity (a person, company, etc.). Like a handwritten signature, a digital signature has many useful characteristics:

Its authenticity can be verified, via a computation that uses the public key corresponding to the private key used to generate the signature. It cannot be forged, assuming the private key is kept secret. It is a function of the data signed and thus can't be claimed to be the signature for other data as well.

The signed data cannot be changed; if it is, the signature will no longer verify as being authentic.

In order for an entity's signature to be generated for a file, the entity must first have a public/private key pair associated with it, and also one or more certificates authenticating its public key. A certificate is a digitally signed statement from one entity, saying that the public key of some other entity has a particular value.

jarsigner uses key and certificate information from a keystore to generate digital signatures for JAR files. A keystore is a database of private keys and their associated X.509 certificate chains authenticating the corresponding public keys. The keytool utility is used to create and administer keystores.

jarsigner uses an entity's private key to generate a signature. The signed JAR file contains, among other things, a copy of the certificate from the keystore for the public key corresponding to the private key used to sign the file. jarsigner can verify the digital signature of the signed JAR file using the certificate inside it (in its signature block file).

Starting in J2SE 5.0, jarsigner can generate signatures that include a timestamp, thus enabling systems/deployer (including Java Plug-in) to check whether the JAR file was signed while the signing certificate was still valid. In addition, APIs were added in J2SE 5.0 to allow applications to obtain the timestamp information.

At this time, jarsigner can only sign JAR files created by the SDK jar tool or zip files. (JAR files are the same as zip files, except they also have a META-INF/MANIFEST.MF file. Such a file will automatically be created when jarsigner signs a zip file.)

The default jarsigner behavior is to sign a JAR (or zip) file. Use the -verify option to instead have it verify a signed JAR file.

Official source: http://docs.oracle.com/javase/8/docs/technotes/tools/windows/jarsigner.html

336 questions
5
votes
1 answer

Xamarin.Forms android application built from command line doesn't work

I have a Xamarin.Forms Android application, developed using Visual Studio 2017. If I run/debug the application from Visual studio, with a USB device, it works well (both debug and release configurations). I then create the .apk using the archive…
Franco Tiveron
  • 2,364
  • 18
  • 34
5
votes
2 answers

Jarsigner issue with jre/lib/ext removal

According to this article : https://blogs.oracle.com/java-platform-group/planning-safe-removal-of-under-used-endorsed-extension-directories the jre/lib/ext removed in Java 9. My problem is that I am using Jarsigner which in previous Java versions…
Saar peer
  • 817
  • 6
  • 21
5
votes
1 answer

"APK Signature Scheme v2" is supported only by "apksigner" not by "jarsigner"

We use HSM for APK signing and in order to support new "APK Signature Scheme v2" do we need to use apksigner going forward to support both Scheme 1 & 2? jarsigner - supports only "APK Signature Scheme v1" (JAR-based signing scheme) apksigner -…
5
votes
1 answer

Android - apk-signing: entries' certificate chain is not validated & signatures w/o a timestamp

After following the procedure in Signing your APP with the ADT plugin for Eclipse, I verified manually the signed apk (described below in the same page) with: $ jarsigner -verify -verbose -certs my_application.apk And every entry was signed…
Armfoot
  • 4,663
  • 5
  • 45
  • 60
5
votes
1 answer

Verify and Sign a Jar programmatically

I am new to this topic, therefore I hope I use the right vocabulary. Is it possible to get the possibility of Jarsigner within Java self? I need the possibility to do the following things programatically: verify if a jar is signed with a certain…
gillesB
  • 1,061
  • 1
  • 14
  • 30
5
votes
3 answers

jarsigner -verify works in Java 6 but not Java 7

I've been banging my head against this for a few days and am completely stumped. Here's the rundown: I've got an Eclipse plugin project using Tycho to build via Maven 3 Within Maven I've got the maven-jarsigner-plugin set up to sign jars using my…
Jason Nichols
  • 11,603
  • 5
  • 34
  • 53
5
votes
1 answer

Java Applet - "Block potentially unsafe components from being run?" message

Since the latest Java update, two of my applets are displaying a warning pop-up to our users even though both of the jar files we are using are signed. I have verified they are signed using the jarsigner -verify MyJarFile.jar command. Below is the…
gwin003
  • 7,432
  • 5
  • 38
  • 59
5
votes
1 answer

Signing jar with timestamp and authentication at the timestamp server

I want to use the timestamp option -tsa of the java jarsigner tool. The timestamp service I have in mind requires authentication. For this purpose you get a personalized soft token to identify yourself at the timestamp server. My question: Is this…
Claude
  • 1,724
  • 3
  • 17
  • 46
5
votes
1 answer

android - the apk must be signed with the same certificates as the previous version

I am trying to upload my Android app to the Google Play market and I get the error: the apk must be signed with the same certificates as the previous version The funny thing is I am using the original keystone with the original passwords, so I am…
James Testa
  • 2,901
  • 4
  • 42
  • 60
5
votes
2 answers

Is it possible to re-sign a Java applet with a newer certificate?

I have a signed Java applet, and the certificate just expired. I have a new certificate, but I'm not sure that I can find the original, unsigned applet jar file. Is there any way that I can take the signed jar and replace the old certificate with a…
jay
  • 1,524
  • 4
  • 25
  • 45
4
votes
6 answers

How do I force jarsign to sign jarfiles?

Our product is halted at Java version 1.5.0_13 and we would like to upgrade. Our software deploys a large number of jars via Java Web Start; all of these jars must be signed. However, a couple of the jars do not contain class files, and starting…
skiphoppy
  • 97,646
  • 72
  • 174
  • 218
4
votes
2 answers

Is it possible to have SHA1-Digest in java Manifest file without actually using a key

Currently we use jarsigner to sign our jar. We then display some SHA1-Digest values for some specific classes to prove to an external auditor that the code has not changed between releases. We only rely on the META-INF/xxx.SF file to get the digest…
cbliard
  • 7,051
  • 5
  • 41
  • 47
4
votes
0 answers

Eclipse p2 NoSuchAlgorithmException: No algorithm found for 1.2.840.113549.1.1.11

After signing our jars in our RCP products, the materialization phase stated to fail with: java.security.NoSuchAlgorithmException: No algorithm found for 1.2.840.113549.1.1.11 This tycho build has been running for years. After a lot of research and…
Alain P
  • 1,293
  • 8
  • 16
4
votes
0 answers

Extract the certificate from a signed jar

Given a Java jar file that has been signed with jarsigner (by someone else, so I don't have the original input files), how can I extract the certificate? jarsigner -verify -verbose -certs doesn't show as much information as openssl x509 -text so I…
user2404501
4
votes
1 answer

How to verify signature on self signed jar?

I've signed my jar with a key that I generated using keytool. At runtime, how do I verify that the jar hasn't been modified? The goal is to use the certificate information and verify that each class in the jar has not been modified since the jar…
Justin Kredible
  • 8,354
  • 15
  • 65
  • 91