Fix missing jar entry certificates

Ensure that the source jar entry is closed before reading
certificates and code signers from the entry.

gh-19041
This commit is contained in:
Phillip Webb
2020-09-15 08:42:58 -07:00
parent d73ee9d545
commit e0030094e2
2 changed files with 9 additions and 5 deletions

View File

@@ -353,11 +353,12 @@ class JarFileEntries implements CentralDirectoryVisitor, Iterable<JarEntry> {
try (JarInputStream certifiedJarStream = new JarInputStream(this.jarFile.getData().getInputStream())) {
java.util.jar.JarEntry certifiedEntry = null;
while ((certifiedEntry = certifiedJarStream.getNextJarEntry()) != null) {
// Entry must be closed to trigger a read and set entry certificates
certifiedJarStream.closeEntry();
int index = getEntryIndex(certifiedEntry.getName());
if (index != -1) {
certifications[index] = JarEntryCertification.from(certifiedEntry);
}
certifiedJarStream.closeEntry();
}
}
this.certifications = certifications;