Skip to content

Commit 287b7c7

Browse files
martinuyRealCLanger
authored andcommitted
8347847: Enhance jar file support
Reviewed-by: yan Backport-of: 013d9f988559bc7e29449967c4d35b80d692ef11
1 parent 27c0f3c commit 287b7c7

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
@@ -525,6 +525,8 @@ private boolean verifyManifestMainAttrs(Manifest sf, ManifestDigester md)
525525
boolean attrsVerified = true;
526526
// If only weak algorithms are used.
527527
boolean weakAlgs = true;
528+
// If only unsupported algorithms are used.
529+
boolean unsupportedAlgs = true;
528530
// If a ATTR_DIGEST entry is found.
529531
boolean validEntry = false;
530532

@@ -549,6 +551,7 @@ private boolean verifyManifestMainAttrs(Manifest sf, ManifestDigester md)
549551

550552
MessageDigest digest = getDigest(algorithm);
551553
if (digest != null) {
554+
unsupportedAlgs = false;
552555
ManifestDigester.Entry mde = md.getMainAttsEntry(false);
553556
if (mde == null) {
554557
throw new SignatureException("Manifest Main Attribute check " +
@@ -591,12 +594,22 @@ private boolean verifyManifestMainAttrs(Manifest sf, ManifestDigester md)
591594
}
592595
}
593596

594-
// If there were only weak algorithms entries used, throw an exception.
595-
if (validEntry && weakAlgs) {
596-
throw new SignatureException("Manifest Main Attribute check " +
597-
"failed (" + ATTR_DIGEST + "). " +
598-
"Disabled algorithm(s) used: " +
599-
getWeakAlgorithms(ATTR_DIGEST));
597+
if (validEntry) {
598+
// If there were only weak algorithms entries used, throw an exception.
599+
if (weakAlgs) {
600+
throw new SignatureException(
601+
"Manifest Main Attribute check "
602+
+ "failed (" + ATTR_DIGEST + "). "
603+
+ "Disabled algorithm(s) used: "
604+
+ getWeakAlgorithms(ATTR_DIGEST));
605+
}
606+
607+
// If there were only unsupported algorithms entries used, throw an exception.
608+
if (unsupportedAlgs) {
609+
throw new SignatureException(
610+
"Manifest Main Attribute check failed ("
611+
+ ATTR_DIGEST + "). Unsupported algorithm(s) used");
612+
}
600613
}
601614

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

0 commit comments

Comments
 (0)