Skip to content

Conversation

@zomabies
Copy link

@zomabies zomabies commented Nov 6, 2025

Hi, this PR aim to fix signed jar class returning null signers for
CodeSource.getCodeSigner/getCertificate from Class.getProtectionDomain and Class.getSigners

The existing signer support is broken as currently in 0.17.3 (in the commented todo).

if (connection instanceof JarURLConnection) {
manifest = ((JarURLConnection) connection).getManifest();
certificates = ((JarURLConnection) connection).getCertificates();
}
if (manifest == null) {
try (FileSystemUtil.FileSystemDelegate jarFs = FileSystemUtil.getJarFileSystem(path, false)) {
manifest = ManifestUtil.readManifestFromBasePath(jarFs.get().getRootDirectories().iterator().next());
}
}
// TODO
/* JarEntry codeEntry = codeSourceJar.getJarEntry(filename);
if (codeEntry != null) {
cs = new CodeSource(codeSourceURL, codeEntry.getCodeSigners());
} */
}

I have changed Metadata to show if the codeSource has signed manifest.
It is used to return early if not signed to avoid future processing.

If manifest is signed, it will get signer for the specified filename from jar: uri and create a signed CodeSource with it.
- should not be cached since file will have different signer/no signer depending on the manifest. (ie, appended class file)

I also added a property flag to disables this if there is compatibility issue arise.

I have tested this using -Djava.debug.security=scl (valid before jdk24) with expected behavior when loading signed jars.

@Player3324
Copy link
Contributor

I'd change the system property to be a bit more about disabling jar signature loading.

At a first glance the PR looks ok, but I need to have a closer look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants