After update to JDK 8u131 we cannot sign some jars anymore. We are using ant's <signjar>
task for signing. The signing fails with the following error:
[signjar] jarsigner: unable to sign jar: java.io.IOException:
Invalid encoding: redundant leading 0s
It is interesting that sometimes the jars are signed successfully, and sometimes the signing is failed. I found the following bug:
https://bugs.openjdk.java.net/browse/JDK-8175251
There people suggest normalizing a pkcs12 file with the following commands:
openssl pkcs12 -in CodeSign.pfx -out key-and-cert -nodes
openssl pkcs12 -in key-and-cert -export -out CodeSign2.pfx
However, even after performing these commands and using the new key file I still get the same "redundant leading 0s" error.
The temporary workaround is to use JDK 8u112 or older.
Any ideas how to fix this issue?