Skip to content

Commit ed30fce

Browse files
artur-oraclejaikiran
authored andcommitted
8347847: Enhance jar file support
Reviewed-by: rhalade, jnibedita, pkumaraswamy, ahgross, hchao, weijun, mullan
1 parent 38afa4d commit ed30fce

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, 2024, 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
@@ -518,6 +518,8 @@ private boolean verifyManifestMainAttrs(Manifest sf, ManifestDigester md)
518518
boolean attrsVerified = true;
519519
// If only weak algorithms are used.
520520
boolean weakAlgs = true;
521+
// If only unsupported algorithms are used.
522+
boolean unsupportedAlgs = true;
521523
// If a ATTR_DIGEST entry is found.
522524
boolean validEntry = false;
523525

@@ -542,6 +544,7 @@ private boolean verifyManifestMainAttrs(Manifest sf, ManifestDigester md)
542544

543545
MessageDigest digest = getDigest(algorithm);
544546
if (digest != null) {
547+
unsupportedAlgs = false;
545548
ManifestDigester.Entry mde = md.getMainAttsEntry(false);
546549
if (mde == null) {
547550
throw new SignatureException("Manifest Main Attribute check " +
@@ -584,12 +587,22 @@ private boolean verifyManifestMainAttrs(Manifest sf, ManifestDigester md)
584587
}
585588
}
586589

587-
// If there were only weak algorithms entries used, throw an exception.
588-
if (validEntry && weakAlgs) {
589-
throw new SignatureException("Manifest Main Attribute check " +
590-
"failed (" + ATTR_DIGEST + "). " +
591-
"Disabled algorithm(s) used: " +
592-
getWeakAlgorithms(ATTR_DIGEST));
590+
if (validEntry) {
591+
// If there were only weak algorithms entries used, throw an exception.
592+
if (weakAlgs) {
593+
throw new SignatureException(
594+
"Manifest Main Attribute check "
595+
+ "failed (" + ATTR_DIGEST + "). "
596+
+ "Disabled algorithm(s) used: "
597+
+ getWeakAlgorithms(ATTR_DIGEST));
598+
}
599+
600+
// If there were only unsupported algorithms entries used, throw an exception.
601+
if (unsupportedAlgs) {
602+
throw new SignatureException(
603+
"Manifest Main Attribute check failed ("
604+
+ ATTR_DIGEST + "). Unsupported algorithm(s) used");
605+
}
593606
}
594607

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

0 commit comments

Comments
 (0)