1
1
/*
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.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
@@ -525,6 +525,8 @@ private boolean verifyManifestMainAttrs(Manifest sf, ManifestDigester md)
525
525
boolean attrsVerified = true ;
526
526
// If only weak algorithms are used.
527
527
boolean weakAlgs = true ;
528
+ // If only unsupported algorithms are used.
529
+ boolean unsupportedAlgs = true ;
528
530
// If a ATTR_DIGEST entry is found.
529
531
boolean validEntry = false ;
530
532
@@ -549,6 +551,7 @@ private boolean verifyManifestMainAttrs(Manifest sf, ManifestDigester md)
549
551
550
552
MessageDigest digest = getDigest (algorithm );
551
553
if (digest != null ) {
554
+ unsupportedAlgs = false ;
552
555
ManifestDigester .Entry mde = md .getMainAttsEntry (false );
553
556
if (mde == null ) {
554
557
throw new SignatureException ("Manifest Main Attribute check " +
@@ -591,12 +594,22 @@ private boolean verifyManifestMainAttrs(Manifest sf, ManifestDigester md)
591
594
}
592
595
}
593
596
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
+ }
600
613
}
601
614
602
615
// this method returns 'true' if either:
0 commit comments