-
Bug
-
Resolution: Fixed
-
P4
-
17, 21, 22, 23
-
b22
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8353915 | 21.0.8 | Satyen Subramaniam | P4 | Resolved | Fixed | master |
Consider this trivial application code:
import java.security.*;
public class KeyStoreTest {
public static void main(final String[] args) throws Exception {
final KeyStore ks = KeyStore.getInstance("PKCS12");
System.out.println("Got keystore " + ks);
}
}
When compiled and run without any additional security properties as follows, it works fine:
java KeyStoreTest
Got keystore java.security.KeyStore@6b884d57
Now create a file "/tmp/app-security.properties" file with the following contents (it sets a security property)
jdk.security.provider.preferred=KeyStore.PKCS12:JipherJCE
and run that program as follows by passing "/tmp/app-security.properties" to -Djava.security.properties:
java -Djava.security.properties=/tmp/app-security.properties KeyStoreTest
This time it throws a NullPointerException:
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "java.security.Provider.getService(String, String)" because "p" is null
at java.base/sun.security.jca.ProviderList.getService(ProviderList.java:376)
at java.base/sun.security.jca.GetInstance.getInstance(GetInstance.java:157)
at java.base/java.security.Security.getImpl(Security.java:658)
at java.base/java.security.KeyStore.getInstance(KeyStore.java:870)
at KeyStoreTest.main(KeyStoreTest.java:7)
I ran this on Java 22 but is applicable for lower Java versions too.
import java.security.*;
public class KeyStoreTest {
public static void main(final String[] args) throws Exception {
final KeyStore ks = KeyStore.getInstance("PKCS12");
System.out.println("Got keystore " + ks);
}
}
When compiled and run without any additional security properties as follows, it works fine:
java KeyStoreTest
Got keystore java.security.KeyStore@6b884d57
Now create a file "/tmp/app-security.properties" file with the following contents (it sets a security property)
jdk.security.provider.preferred=KeyStore.PKCS12:JipherJCE
and run that program as follows by passing "/tmp/app-security.properties" to -Djava.security.properties:
java -Djava.security.properties=/tmp/app-security.properties KeyStoreTest
This time it throws a NullPointerException:
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "java.security.Provider.getService(String, String)" because "p" is null
at java.base/sun.security.jca.ProviderList.getService(ProviderList.java:376)
at java.base/sun.security.jca.GetInstance.getInstance(GetInstance.java:157)
at java.base/java.security.Security.getImpl(Security.java:658)
at java.base/java.security.KeyStore.getInstance(KeyStore.java:870)
at KeyStoreTest.main(KeyStoreTest.java:7)
I ran this on Java 22 but is applicable for lower Java versions too.
- backported by
-
JDK-8353915 NullPointerException in sun.security.jca.ProviderList.getService()
-
- Resolved
-
- links to
-
Commit openjdk/jdk/cd3a6075
-
Commit(master) openjdk/jdk21u-dev/6cd096eb
-
Review openjdk/jdk/18746
-
Review(master) openjdk/jdk17u-dev/3442
-
Review(master) openjdk/jdk21u-dev/1598
(1 links to)