Skip to content

Commit 898c0ef

Browse files
martinuygnu-andrew
authored andcommitted
8347847: Enhance jar file support
Reviewed-by: yan, andrew Backport-of: ef84ee26d6891c824eb798863f4ef9334e473bb8
1 parent 68d10da commit 898c0ef

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

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

+20-7
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
@@ -503,6 +503,8 @@ private boolean verifyManifestMainAttrs(Manifest sf, ManifestDigester md)
503503
boolean attrsVerified = true;
504504
// If only weak algorithms are used.
505505
boolean weakAlgs = true;
506+
// If only unsupported algorithms are used.
507+
boolean unsupportedAlgs = true;
506508
// If a ATTR_DIGEST entry is found.
507509
boolean validEntry = false;
508510

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

528530
MessageDigest digest = getDigest(algorithm);
529531
if (digest != null) {
532+
unsupportedAlgs = false;
530533
ManifestDigester.Entry mde =
531534
md.get(ManifestDigester.MF_MAIN_ATTRS, false);
532535
if (mde == null) {
@@ -570,12 +573,22 @@ private boolean verifyManifestMainAttrs(Manifest sf, ManifestDigester md)
570573
}
571574
}
572575

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

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

0 commit comments

Comments
 (0)