I have a java project that is built with maven. During the package phase, the code is built into a jar (maven-jar-plugin 3.1.1) and is wrapped into an .exe (launch4j-maven-plugin 1.7.25)
Part of my code opens the .exe as a file system to fetch resources. Specifically, using java.nio.file.FileSystems.newFileSystem(URL url), passing in the exe
This file system properly properly identifies that my file is indeed a wrapped jar, and reads it as such.
This all breaks down when I try to digitally sign my .exe file. After digitally signing it, I can no longer open the exe as a filesystem in Java. The specific error I have narrowed it down to is at ZipFileSystem.java:991
// Now scan the block backwards for END header signature
for (int i = buf.length - ENDHDR; i >= 0; i--) {
if (buf[i+0] == (byte)'P' &&
buf[i+1] == (byte)'K' &&
buf[i+2] == (byte)'\005' &&
buf[i+3] == (byte)'\006' &&
(pos + i + ENDHDR + ENDCOM(buf, i) == ziplen)) { -- this check fails. We find the header name, but the size check fails.
So, digitally signing the .exe file added some amount of bytes to my file size, and is causing the jar file's integrity check to always fail. I have tried signing the jar before wrapping (jarsigner), signing the exe after with both Advanced Installer Program and Jsign, and have not been able to remedy this issue.
Having the jar wrapped in an exe that is then signed, causes the jar to become unreadable by java.nio.file.FileSystems. What can I do to fix this? Is there a signer that will know to update the jar's integrity check value? Any help is appreciated