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

328 questions
19
votes
2 answers

BouncyCastle Cryptography provider library used with applet on Java 7u40

The case: I am maintaining a Java applet which uses the BouncyCastle libraries bcpkix-jdk15on-149.jar, and bcprov-jdk15on-149.jar. Problem is when the applet is run on a JRE version 7_u40 enabled browser. The behavior has changed from version 7_u25…
Steph V.
  • 511
  • 3
  • 9
18
votes
4 answers

Jarsigner is not recognized internal or external command

i'm trying to check if my signed release apk is really signed. But following some tutorials, or the single i've found . $ jarsigner -verify -verbose -certs my_application.apk I am receiving this message : "Jarsigner is not recognized internal…
Leogreen
  • 631
  • 1
  • 5
  • 16
18
votes
3 answers

What prevents Java from verifying signed jars with multiple signature algorithms

Quick background: We release a webstart application, which includes our own application jars and numerous third-party jars. Webstart requires that all distributed jars referred to by the jnlp file be signed by a single certificate. We therefore…
JimN
  • 3,007
  • 19
  • 34
18
votes
7 answers

jarsigner error: java.lang.RuntimeException: keystore load: Keystore was tampered with, or password was incorrect

I am trying to sign a .wgt file(widget which is a jar file) using jarsigner of Java 6. But when I try to sign, it gives me the following error, after asking to enter the passphrase for keystore. jarsigner error: java.lang.RuntimeException: keystore…
Pushpalanka
  • 807
  • 1
  • 8
  • 19
17
votes
1 answer

openssl fails to produce a pfx with a valid alias

I am trying to generate a pfx file to use as a signing mechanism for some JAR files as per these instructions. To create the pfx file I am using the following command openssl pkcs12 -export -in my-cert.crt -inkey my-priv-key.key -certfile…
user3198232
  • 173
  • 1
  • 1
  • 4
16
votes
2 answers

What is the difference between the Java 1.6 and 1.7 jarsigner

Just noted that you can´t sign Android APKs with the Java 1.7 jarsigner. So I wonder why this is and what is the difference between the 1.6 and 1.7 signer?
Martin
  • 10,876
  • 14
  • 76
  • 102
14
votes
2 answers

Sign Android App Bundle from Command Line

anyone know how to sign .aab file using new keystore from command line? The documentation here mentions that we can use jarsigner to sign our app bundle from the command line. but I cannot find the command line? Anyone know the command line? I got…
hallz12
  • 359
  • 5
  • 12
13
votes
3 answers

Android signing error: trusted certificate entries are not password-protected

Got a certificate to sign the android unsigned release apk files, So I imported the cer using command: keytool -import -alias alias_name -file cer_name.cer -storepass changeit -keystore my_keystore.keystore But when signing the app with android…
Sanjay Singh
  • 151
  • 1
  • 10
12
votes
2 answers

Extract raw X.509 Certificate from a signed APK or JAR

I have a library of MD5 hashes of public keys used to sign various jars, and a mapping to their respective keystores which we use to sign different APKs. What I'd like to be able to do is identify which keystore was used to sign an APK, but without…
Jeff DQ
  • 457
  • 1
  • 4
  • 11
11
votes
4 answers

jarsigner "Only one alias can be specified"

In Windows command prompt: >keytool -genkey -alias me >keytool -selfcert -alias me >jarsigner myJar.jar me Only one alias can be specified I have failed to find any info on this error on the web. I'm obviously only specifying one alias here. What…
unmuse
  • 607
  • 2
  • 8
  • 21
8
votes
1 answer

Using the JarSigner with RSASSA-PSS

Im trying to RSA-PSS-sign a JAR file with the JarSigner using PKCS#11. To specify the signature algorithm the JarSigner uses the sigalg flag. The JDK 14 Docs of the JarSigner does not specify which sigalgs are explicitly supported. I have tested…
D.O.
  • 227
  • 1
  • 5
8
votes
2 answers

Spring boot doesn't read Components after jar signing

I am developing a Spring Boot Application that serves REST HTTP(S) requests. (pretty common). It works as it is supposed, but after the final (and working) jar is signed (by a valid certificate) all URL mappings stop working, returning only 404 to…
Jairton Junior
  • 554
  • 3
  • 13
7
votes
3 answers

Jarsigner: "This jar contains entries whose certificate chain is not validated."

I get the following error on a self-signed jar: jar verified. Warning: This jar contains entries whose certificate chain is not validated. Re-run with the -verbose and -certs options for more details. I signed the jar like this: "C:\Program…
Joel
  • 3,361
  • 4
  • 35
  • 58
7
votes
1 answer

How can I dump the signature of an Android App Bundle?

I'm switching my CI process from producing APK files to App Bundles. One stage in my pipeline will, after producing the signed binary, dump the signature and validate the signature on the APK to make sure it's signed properly before continuing. >…
Aidan64
  • 333
  • 1
  • 3
  • 7
7
votes
1 answer

Signing java 11 jar with jarsigner duplicate entry module-info.class

Hi I am new with java modules so this might be a dumb question. I was trying to sign my jar file with keystore and got the following error. user@Ubuntu:libs(master)$ jarsigner -keystore keyStoreFileName Test.jar alias Enter Passphrase for keystore:…
Coding Otaku
  • 181
  • 2
  • 14
1
2
3
21 22