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
2
votes
2 answers

Which elliptic curves does jarsigner support?

I will be signing JARs with an ECDSA key, and I can choose now which elliptic curve I will use. I at least need to be able to generate the signature with jarsigner. Where can I see, what elliptic curves jarsigner supports? I tested that out of 65…
Konstantin Shemyak
  • 2,369
  • 5
  • 21
  • 41
2
votes
1 answer

Why does apk signing with jarsigner give java.security.NoSuchAlgorithmException: SHA11 MessageDigest not available?

I'm trying to sign an apk with a keystore. When I enter this: \bin>jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA11 -keystore .mykeystore MY.apk ALIAS Enter Passphrase for keystore: I get this error: jarsigner error:…
Diego
  • 4,011
  • 10
  • 50
  • 76
2
votes
1 answer

jarsigner doesn't work Ubuntu

I am trying to figure out how to sign apk with android debug key but when I use jarsigner after deleting meta from apk, I get the following error: https://i.stack.imgur.com/ltOMv.png Please help. I have java -version showing installed.…
user3930695
  • 31
  • 2
  • 5
2
votes
1 answer

Maven jar signer plugin

i have a problem with jar signer plugin. i'm in a legacy project that use an applet, all applet jar need to be signed. first of all, i have add jar-signer plugin in each applet project. but i need to add a common module into the applet, so i have…
2
votes
1 answer

Sign jar with certificate but without private key

I have a basic question about signing a jar file with a provided certificate. I have a certificate(.pem file) that I wish to use to sign a jar. I do not have its private key. The command that I used till now is: jarsigner -keystore /working/mystore…
Aspirant
  • 1,934
  • 4
  • 25
  • 44
2
votes
1 answer

Self signing jar file, doesn't find JarSigner class

I'm trying to sign my java applet. I ran the following lines to create a cert: keytool -genkey -keystore myKeyStore -alias ben keytool -selfcert -keystore myKeyStore -alias ben up to here everything works well. It requires a password and some…
user1028741
  • 2,745
  • 6
  • 34
  • 68
2
votes
1 answer

Unable to install a release build of APK

I created an app that worked well in the emulator and in devices when tested. I then used the export option to generate a signed APK for release. But this APK is not installing and is showing the error message "unable to install" when installed from…
2
votes
1 answer

Creating keystore for jarsigner programmatically

I'm trying to generate keystore with certificate to use it with JarSigner. Here is my code: System.out.println("Keystore generation..."); Security.addProvider(new BouncyCastleProvider()); String domainName = "example.org"; …
skayred
  • 10,603
  • 10
  • 52
  • 94
2
votes
1 answer

Sign JAR programmatically

I want to sign a JAR with my code and without keystores - using only private user's key (because I have a lot of users and keys). I've found the same question, but it uses keystores, and I want to do it using only PrivateKey or String. Is it…
skayred
  • 10,603
  • 10
  • 52
  • 94
2
votes
0 answers

How to Create default .keystore file OR restore .keystore

When I try to run calabash-android resign ContactManager.apk I get Following Error. 2013-04-03 21:29:38 - "C:\Java\jdk1.7.0_17/bin/jarsigner.exe" -sigalg MD5withRSA -digestalg SHA1 -signedjar…
2
votes
1 answer

“Package file was not signed correctly” error upon installation

I created an Android app and published it within the Google Play Store. Upon subsequent download, I receive the “Package file was not signed correctly” error. I investigated and found the entry: Published Android apk gives error "Package file was…
Perry Hoekstra
  • 202
  • 2
  • 9
2
votes
1 answer

Folder permission issue with jarsigner

This is definitely a very beginner question that might not have to do anything with programming. After few days, I have finally identified the problem as for why I couldn't sign jar using jarsigner. I kept getting this error that says "jarsigner:…
user1142285
  • 119
  • 2
  • 10
2
votes
3 answers

Launching jarsigner.exe on windows os which jdk/jre not installed by installer

I've embedded jre files to my applications setup, i can use java.exe to perform some java specific tasks. And i want to use jarsigner.exe but when i launch jarsigner, it checks some registry keys, and could not found (because jre is not insatalled…
tutalia
  • 285
  • 3
  • 16
2
votes
2 answers

How to sign jar using jarsign without providing -storepass?

Using jarsign without -storepass will prompt for the keystore password, which will break our automated build (no human intervention) If we use jarsign with -storepass, then this will effectively log the password in cleartext in the build log. Is…
Long Vu
  • 281
  • 1
  • 10
1
vote
2 answers

App won't install : CertPath not validated: null

I have written an Android app (target 3.2) using Eclipse 3.7, I tried to sign the App, but on the target machine, either the App won't install or it installed but doesn't run with "application is not installed" error. In debug mode the app works…