Skip to content

Commit

Permalink
Ensure static fields set during signed jar process
Browse files Browse the repository at this point in the history
When loading a signed jar file that is on the classpath, such as the
bouncy castle signed JCE jar file, it has been observed that the value
of `restrictedJarVerificationProviders` and `jarVerificationProviders`
are set to `null`. This causes a NullPointerException during the loading
process.

This update moves the static declarations of both
`restrictedJarVerificationProviders` and `jarVerificationProviders` to
be prior to the method call `RestrictedSecurity.checkHashValues()` since
this method call needs both of these fields to be initialized to work
correctly.

Signed-off-by: Jason Katonica <katonica@us.ibm.com>
  • Loading branch information
jasonkatonica committed Sep 18, 2024
1 parent 5998a93 commit ebc2e49
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/java.base/share/classes/sun/security/jca/Providers.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,6 @@ public class Providers {
// Note volatile immutable object, so no synchronization needed.
private static volatile ProviderList providerList;

static {
// set providerList to empty list first in case initialization somehow
// triggers a getInstance() call (although that should not happen)
providerList = ProviderList.EMPTY;
providerList = ProviderList.fromSecurityProperties();
RestrictedSecurity.checkHashValues();
}

private Providers() {
// empty
}
Expand Down Expand Up @@ -113,6 +105,14 @@ private Providers() {
"com.sun.crypto.provider.SunJCE",
};

static {
// set providerList to empty list first in case initialization somehow
// triggers a getInstance() call (although that should not happen)
providerList = ProviderList.EMPTY;
providerList = ProviderList.fromSecurityProperties();
RestrictedSecurity.checkHashValues();
}

// Return Sun provider.
// This method should only be called by
// sun.security.util.ManifestEntryVerifier and java.security.SecureRandom.
Expand Down

0 comments on commit ebc2e49

Please sign in to comment.