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
1
vote
1 answer

Signed jar file recognized in java 1.7.0_76 but not java 1.7.0_75

I signed a jar file using the signer provided with jdk 1.7.0_71. This also worked previously until we updated from X.509, CN=GlobalSign CodeSigning CA - SHA256 - G2, O=GlobalSign nv-sa to X.509, CN=GlobalSign CodeSigning CA - SHA256 - G3,…
Florian
  • 388
  • 2
  • 3
  • 13
1
vote
1 answer

JarSigner Ant.signjar working for jar file without dependencies but not working for jar when including dependencies in Gradle Script

I am trying to sign a Jar file using ant.signjar, it's working fine when I create a Jar file which doesn't include any dependencies, but when I include dependencies for jar file then it throws me error saying jarsigner returned: 1 Gradle Script(for…
1
vote
1 answer

I can't timestamp my .apk

I'm trying to sign an .apk to export it on the android store, but any how I try to sign it with a timestamp server, I fail making it works: "Certificate expires before the actual date"... What i have tried: Jarsigner -tsa…
NoP
  • 15
  • 6
1
vote
1 answer

Jar signing Java 6 vs Java 8

I have a signed jar. With Java 7/8 my application has no issues. With Java 6 it complains about unsigned entry in jar. I verified the jar using jarsigner -verify myjar.jar Output Java 7, Java8 -> "jar verified" Output Java 6 -> "jar is unsigned.…
Joschi
  • 2,118
  • 3
  • 16
  • 32
1
vote
1 answer

How to Sign apk programmatically in java / by using command line

I am working on phonegap project. I have one apk file which is working fine and installing properly on android device, but I want to do some modification in that apk file, for that what i am doing is, just renaming it's extention from apk to zip and…
1
vote
1 answer

Can not verify rule set jar

Another try to open a message here My company wants to use the deployment rule set for multiple java versions usage. Currenly we have 1.6.0_13, 1.7.0_51 and 1.8.0_66 Java 8 is what selected in the System tab of the java control home User tab…
jack
  • 273
  • 3
  • 4
  • 14
1
vote
1 answer

Cannot sign apk with old certificate

The current version of my apk in Android Play is from 23.01.2011. At that time it was possible to create a key without using algorithms in the options. From 08.2012 I had to create a new key store using the options -sigalg MD5withRSA -keyalg RSA…
elxala
  • 291
  • 3
  • 5
1
vote
1 answer

Why isn't my generated keystore file showing up?

I have generated my keystore file according to the Android Studio directions. When I tried to sign it using jarsigner, I ran into an error. I thought I could just skip this step and use my keystore file to generate an android build, but when I…
1
vote
1 answer

Failed to read key xxxx from store "/Users/liuyue/work/keyStore/CeLueChaoGu.jks": Keystore was tampered with, or password was incorrect

I met a very stupid and strange question: Failed to read key xxxx from store "/Users/liuyue/work/keyStore/CeLueChaoGu.jks": Keystore was tampered with, or password was incorrect; but, it's different from the other questions, platform is OSX in…
LiuYue
  • 11
  • 1
1
vote
1 answer

How can I prevent jarsign script from overwriting existing Manifest values in signed jars?

I am building an Eclipse plugin which I want to deliver with signed jars. After using Eclipse UI for creating the update site and building the plugins and features from there manually I want to sign the created jars. Doing so leads to the…
Markus
  • 2,071
  • 4
  • 22
  • 44
1
vote
1 answer

Verifying an APK programmatically using JarSigner

I want to use verify an APK from Java code using JarSigner. I am writing an app that programatically installs APKs (much like Google Play) and before installing it checks for the following: Verify the signature of the .SF file itself.Verify the…
Sai
  • 2,089
  • 3
  • 19
  • 30
1
vote
1 answer

Java Jarsigner does not use provided Proxy

I cannot get Jarsigner to use HTTPS Proxy. For my system I have configured the http & https proxy in /etc/sysconfig/proxy. I have even added proxy in Java Control. Checking with wget and the proxy does work: user@machineLinx:~/workspace/myApp> wget …
DJViking
  • 832
  • 1
  • 12
  • 29
1
vote
1 answer

Sign .apk file without password prompting on local phonegap

Hi there I am trying to sign my unsigned .apk file without prompting the password. The android build is local on phonegap/cordova via cmd/powershell. The signing-step should be done with jarsigner via cmd too.Unfortunately there is no official…
1
vote
2 answers

Maven: JAVA_HOME/lib/tools.jar as dependency

Im new to Maven. I must use class sun.security.tools.JarSigner in my project.Im trying add tools.jar as dependency.I proceeded by Maven's FAQ, other articles from stackowerflow and google but without some positive results. My NetBean can "see"…
Krakonos
  • 23
  • 2
  • 4
1
vote
2 answers

Using pack200 on signed jar file

I have a jar file of size ~45MBs. I have used Pack200 to compress the jar file and then sign it with 3rd party certificate as follows : pack200 --repack a.jar jarsigner a.jar ... .. pack200 a.jar.pack.gz a.jar Using the above leads to an…
Nayan Sonthalia
  • 237
  • 1
  • 4
  • 22