Skip to content

Commit 9b1635b

Browse files
committed
took into account breaking change in Java 21 - relates to github #1826
1 parent a1ed964 commit 9b1635b

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

prov/src/main/java/org/bouncycastle/jce/provider/BouncyCastleProvider.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,8 @@ public final Service getService(final String type, final String algorithm)
276276
public Service run()
277277
{
278278
Service service = BouncyCastleProvider.super.getService(type, algorithm);
279-
if (service == null)
279+
// from Java21 services started to return with null class names...
280+
if (service == null || service.getClassName() == null)
280281
{
281282
return null;
282283
}

prov/src/test/java/org/bouncycastle/jce/provider/test/AlgorithmParametersTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.io.IOException;
44
import java.security.AlgorithmParameters;
5+
import java.security.GeneralSecurityException;
56
import java.security.Security;
67
import java.security.spec.AlgorithmParameterSpec;
78
import java.security.spec.DSAParameterSpec;
@@ -98,10 +99,25 @@ private void basicTest(String algorithm, Class algorithmParameterSpec, byte[] as
9899
}
99100
}
100101

102+
private void java21NullCheck()
103+
throws Exception
104+
{
105+
try
106+
{
107+
AlgorithmParameters algParams = AlgorithmParameters.getInstance("1.2.840.113549.1.1.1", "BC");
108+
fail("no exception");
109+
}
110+
catch (GeneralSecurityException e)
111+
{
112+
// okay..
113+
}
114+
}
115+
101116
public void performTest()
102117
throws Exception
103118
{
104119
basicTest("DSA", DSAParameterSpec.class, dsaParams);
120+
java21NullCheck();
105121

106122
AlgorithmParameters al = AlgorithmParameters.getInstance("EC", "BC");
107123

0 commit comments

Comments
 (0)