Certificate chain not found, but keystore contains private key

tobbe picture tobbe · Dec 18, 2014 · Viewed 10k times · Source

Im trying to sign my apk so I can release an update to my app with this command: jarsigner ­-verbose -sigalg SHA1withRSA -­digestalg SHA1 ­-keystore my­release-key.keystore CordovaApp­release­unsigned.apk alias_name but getting this error:

jarsigner: Certificate chain not found for: ¡sigalg.  ¡sigalg must reference a valid KeyStore key entry containing a private key and corresponding public key certificate chain.

I´ve just moved to a new computer so I copied my .keystore file to it. When I do keytool -list -v it seems like it contains the private key, so I dont understand whats wrong.. Is the public key missing? enter image description here

Answer

Omikron picture Omikron · Dec 20, 2014

Obviously it was an encoding issue. The command contained characters that looked similar to a minus sign (ASCII code 0x2D), but actually were one of the many dash or hyphen characters (http://en.wikipedia.org/wiki/Dash).

Because of the wrong character code the first parameter "-verbose" was recognised by jarsigner not as an option but as the name of the jar file and "-sigalg" was recognised as the alias:

Usage: jarsigner [options] jar-file alias

This explains why the alias in the error message was "¡sigalg" and not the actual alias from the command and contained an inverted exclamation mark at the beginning (this used to be the "-" in another character set).