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
@@ -501,6 +501,8 @@ private boolean verifyManifestMainAttrs(Manifest sf, ManifestDigester md)
501
501
boolean attrsVerified = true ;
502
502
// If only weak algorithms are used.
503
503
boolean weakAlgs = true ;
504
+ // If only unsupported algorithms are used.
505
+ boolean unsupportedAlgs = true ;
504
506
// If a ATTR_DIGEST entry is found.
505
507
boolean validEntry = false ;
506
508
@@ -525,6 +527,7 @@ private boolean verifyManifestMainAttrs(Manifest sf, ManifestDigester md)
525
527
526
528
MessageDigest digest = getDigest (algorithm );
527
529
if (digest != null ) {
530
+ unsupportedAlgs = false ;
528
531
ManifestDigester .Entry mde = md .getMainAttsEntry (false );
529
532
if (mde == null ) {
530
533
throw new SignatureException ("Manifest Main Attribute check " +
@@ -567,12 +570,22 @@ private boolean verifyManifestMainAttrs(Manifest sf, ManifestDigester md)
567
570
}
568
571
}
569
572
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
+ }
576
589
}
577
590
578
591
// this method returns 'true' if either:
0 commit comments