I test the following on jdk11:
/opt/jdk11/bin/keytool -printcert -v -file <(cat mycert.pem)
And prints the certificate details as expected.
But if I do the same with jdk17 version of keytool I get an exception:
/opt/jdk17/bin/keytool -printcert -v -file <(cat mycert.pem)
keytool error: java.io.IOException: Illegal seek
java.io.IOException: Illegal seek
at java.base/java.io.FileInputStream.position0(Native Method)
at java.base/java.io.FileInputStream.position(FileInputStream.java:363)
at java.base/java.io.FileInputStream.readAllBytes(FileInputStream.java:281)
at java.base/sun.security.tools.keytool.Main.generateCertificates(Main.java:2804)
at java.base/sun.security.tools.keytool.Main.printCertFromStream(Main.java:2762)
at java.base/sun.security.tools.keytool.Main.doPrintCert(Main.java:2961)
at java.base/sun.security.tools.keytool.Main.doCommands(Main.java:1286)
at java.base/sun.security.tools.keytool.Main.run(Main.java:415)
at java.base/sun.security.tools.keytool.Main.main(Main.java:408)
But the following works:
/opt/jdk17/bin/keytool -printcert -v -file mycert.pem
Clearly process substitution does not work with jdk17 keytool. My question is the following:
Is there a bash workaround to fix this?
Should this be considered a bug of jdk17 keytool and if yes what is the code that I should avoid in order to make my java programs friendly to bash process substitution?