Certificate chain not found, but keystore contains private key
I’m trying to sign my apk so that I can release my app update with the following command: jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore myrelease-key.keystore CordovaApprelease unsigned.apk alias_ name
But you get 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
just moved to a new computer, so I copied my .keystore file onto it. When I do keytool -list -v
, it seems to contain the private key, so I don’t understand what’s wrong. Is the public key lost?
Solution
Apparently this is a coding issue. The command contains characters that look like a minus sign (ASCII code 0x2D), but are actually one of many dashes or hyphens (http://en.wikipedia.org/wiki/Dash).
Due to the wrong character code, the first parameter “-verbose
” is recognized by jarsigner as a jar file and “-sigalg
name instead of an option” is recognized as an alias:
Usage: jarsigner [options] jar-file alias
This explains why the alias in the error message is “¡sigalg
” instead of the actual alias of the command, and contains an inverted exclamation mark at the beginning (previously “-” in another character set).