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
122
votes
6 answers

How to convert .pfx file to keystore with private key?

I need to sign Android application (.apk). I have .pfx file. I converted it to .cer file via Internet Explorer and then converted .cer to .keystore using keytool. Then I've tried to sign .apk with jarsigner but it says that .keystore doesn't content…
Ola
  • 1,317
  • 2
  • 11
  • 12
57
votes
6 answers

Certificate chain not found, how to fix and publish to Google Play Store?

ERROR MESSAGE: jarsigner: Certificate chain not found for: project_foo.
project_foo must reference a valid KeyStore key entry containing a private key and corresponding public key certificate chain. QUESTION: How do I include a public key…
campbellwarren
  • 620
  • 1
  • 5
  • 11
55
votes
2 answers

Check android keystore keypass for correctness

I'm automating some things that involve the android keytool and jarsigner. The tool takes a keystore, the password for the keystore, the alias name, and the password for the alias / key, and I'm trying to find a way to explicitly check to see if the…
Narfanator
  • 4,951
  • 3
  • 32
  • 57
54
votes
8 answers

Android keystore stopped working

Just recently I have had a problem with a key store. I know there are plenty of questions about this problem already. I have read them all and Googled furiously. Error: keytool error: java.io.IOException: Keystore was tampered with, or password was…
Jared Burrows
  • 50,718
  • 22
  • 143
  • 180
48
votes
8 answers

jarsigner: This jar contains entries whose certificate chain is not validated

I'm trying to code sign a JAR file and am using JDK 1.7u1. We acquired a GoDaddy Code Signing certificate and I followed the instructions (Approach 1) here: http://help.godaddy.com/article/4780 The JAR signs fine, however whenever I try to run the…
Seth
  • 762
  • 1
  • 6
  • 9
41
votes
8 answers

Published Android apk gives error "Package file was not signed correctly"

I recently uploaded my application to the android market however it's refusing to run when downloaded due to the error Package file was not signed correctly I first published the packet using eclipse, right click export, creating a keystore then…
David Read
  • 615
  • 2
  • 9
  • 12
30
votes
1 answer

How to pass jarsigner.exe passphrase via commandline?

I know that this is unsafe, but is there any easy way to pass passphrase to the jarsigner.exe: jrsigner.exe -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ... Enter Passphrase for keystore: I am running it in batch file.
Stepan Yakovenko
  • 6,197
  • 19
  • 92
  • 176
29
votes
5 answers

You uploaded an APK that was signed in debug mode. You need to sign your APK in release mode error

I am trying to upload an Application on the Google Play store. I am building the .apk and signing it using Maven. I have used maven-jarsigner-plugin to sign the .apk file. I am using the key that I created using Eclipse wizard for signing another…
Nemin
  • 1,607
  • 6
  • 22
  • 37
27
votes
3 answers

Android keystore corrupted

After a while of not updating my applications in the Play Store I tried to sign one of my APK with my keystore, only to find that the keystore and alias password doesn't work anymore. The keystore password I was able to reset using this gist:…
Niels Masdorp
  • 2,214
  • 1
  • 16
  • 29
26
votes
1 answer

Jar Signing Strategy in Maven Projects

We have several maven projects, which are built on the build server. In some cases we want to sign our deliverables. We use Maven Jarsigner Plugin to do that. We face the following questions: Where should we store the passwords for signing? What…
Maksim Sorokin
  • 2,072
  • 1
  • 30
  • 52
26
votes
4 answers

How to verify a jar signed with jarsigner programmatically

I'm wanting to sign a jar using jarsigner, then verify it using a Java application which does not have the signed jar as part of it's classpath (i.e. just using a filesystem location of the jar) Now my problem is getting the signature file out of…
James Carr
  • 797
  • 1
  • 10
  • 21
24
votes
4 answers

What kind of pitfals exist for the Android APK signing?

Disclaimer: I know the basics of signing an APKs and I have a problem with only one of my projects and only when signing with Microsoft Windows as the OS. I am building my APK with Maven and sign them with the maven-jarsigner-plugin:
Martin
  • 10,876
  • 14
  • 76
  • 102
24
votes
4 answers

Jarsigner: certificate chain not found for

I have imported a certificate into a private ~/.keystore file: keytool -list Enter keystore password: Keystore type: JKS Keystore provider: SUN Your keystore contains 1 entry mylyn-mantis, Jul 15, 2010, trustedCertEntry and am trying to sign a…
Robert Munteanu
  • 63,405
  • 31
  • 191
  • 270
24
votes
4 answers

Signing an existing apk using debug.keystore generated by eclipse

I have an existing unsigned apk and I want to sign it using my debug.keystore file. Here I found a tutorial how it can be done. jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore my_application.apk…
Dmitry Guselnikov
  • 999
  • 1
  • 6
  • 19
23
votes
3 answers

How to use jarsigner for signing an apk?

I have very little programming knowledge.I am able to open jar signer through the command prompt then I get various jar signer options,which i do not know how to use them.Can anyone explain me what should i type in the command prompt in order to…
user3143901
  • 243
  • 1
  • 2
  • 5
1
2 3
21 22