Skip to content

Commit 8031251

Browse files
martinuygnu-andrew
authored andcommitted
8347847: Enhance jar file support
Reviewed-by: yan, andrew Backport-of: ff6fb92bd9721e85a6187af262f2fa77d79c7b09
1 parent ea1389c commit 8031251

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -501,6 +501,8 @@ private boolean verifyManifestMainAttrs(Manifest sf, ManifestDigester md)
501501
boolean attrsVerified = true;
502502
// If only weak algorithms are used.
503503
boolean weakAlgs = true;
504+
// If only unsupported algorithms are used.
505+
boolean unsupportedAlgs = true;
504506
// If a ATTR_DIGEST entry is found.
505507
boolean validEntry = false;
506508

@@ -525,6 +527,7 @@ private boolean verifyManifestMainAttrs(Manifest sf, ManifestDigester md)
525527

526528
MessageDigest digest = getDigest(algorithm);
527529
if (digest != null) {
530+
unsupportedAlgs = false;
528531
ManifestDigester.Entry mde = md.getMainAttsEntry(false);
529532
if (mde == null) {
530533
throw new SignatureException("Manifest Main Attribute check " +
@@ -567,12 +570,22 @@ private boolean verifyManifestMainAttrs(Manifest sf, ManifestDigester md)
567570
}
568571
}
569572

570-
// If there were only weak algorithms entries used, throw an exception.
571-
if (validEntry && weakAlgs) {
572-
throw new SignatureException("Manifest Main Attribute check " +
573-
"failed (" + ATTR_DIGEST + "). " +
574-
"Disabled algorithm(s) used: " +
575-
getWeakAlgorithms(ATTR_DIGEST));
573+
if (validEntry) {
574+
// If there were only weak algorithms entries used, throw an exception.
575+
if (weakAlgs) {
576+
throw new SignatureException(
577+
"Manifest Main Attribute check "
578+
+ "failed (" + ATTR_DIGEST + "). "
579+
+ "Disabled algorithm(s) used: "
580+
+ getWeakAlgorithms(ATTR_DIGEST));
581+
}
582+
583+
// If there were only unsupported algorithms entries used, throw an exception.
584+
if (unsupportedAlgs) {
585+
throw new SignatureException(
586+
"Manifest Main Attribute check failed ("
587+
+ ATTR_DIGEST + "). Unsupported algorithm(s) used");
588+
}
576589
}
577590

578591
// this method returns 'true' if either:

0 commit comments

Comments
 (0)