Issue:
When multiple constraints are specified in java.security file to restrict certain algorithm.
Jarsigner doesn't display appropriate error mesage indicating which security property is causing the operation to fail.
Steps to reprodue:
1. Add the constraint "SHA1 jdkCA" to "jdk.jar.disabledAlgorithms" property in java.security file as below:
jdk.jar.disabledAlgorithms=MD2, MD5, RSA keySize < 1024, \
DSA keySize < 1024, include jdk.disabled.namedCurves, \
SHA1 jdkCA
2. Create a jar file (any simple jar).
3. Generate Key pair and rootCA using below keytool command.
i. keytool -genkey -keystore keystoressl.jks -alias "ssl [jdk]" -keyalg RSA -sigalg SHA1withRSA -validity 365 -keysize 1024
ii. keytool -export -alias "ssl [jdk]" -keystore keystoressl.jks -rfc -file out.crt
4. Import this rootaCA (out.crt) to jdk cacerts
i. keytool -import -trustcacerts -keystore $LOCATION_TO_JDK_CA_CERTS
\-storepass changeit -file $LOCATION_TO_ROOT_CA -alias "ssl [jdk]"
5. Sign the jar using SHA1 digest and signature alg.
jarsigner -keystore keystoressl.jks JarSignTester.jar "ssl [jdk]" -sigalg SHA1withRSA -digestalg sha1
6. Verify the jar
jarsigner -verify JarSignTester.jar -keystore keystoressl.jks -verbose -strict
The result look like below:
WARNING: Signature is either not parsable or not verifiable, and the jar will be treated as unsigned. For more information, re-run jarsigner with debug enabled (-J-Djava.security.debug=jar).
If jdkCA is removed from constraint keeping only SHA1, then we get the below descriptive results from jarsigner -verify
WARNING: The jar will be treated as unsigned, because it is signed with a weak algorithm that is now disabled by the security property:
jdk.jar.disabledAlgorithms=MD2, MD5, RSA keySize < 1024, DSA keySize < 1024, include jdk.disabled.namedCurves, SHA1
I observed similar issue on latest jdk-jdk as well.