Skip to content

Commit 1696603

Browse files
committedNov 6, 2023
8308453: Convert JKS test keystores in test/jdk/javax/net/ssl/etc to PKCS12
Reviewed-by: weijun
1 parent b3126b6 commit 1696603

23 files changed

+68
-94
lines changed
 

‎test/jdk/javax/net/ssl/SSLSession/ResumeTLS13withSNI.java

+9-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -438,13 +438,11 @@ private static void checkResumedClientHelloSNI(ByteBuffer resCliHello)
438438
private static TrustManagerFactory makeTrustManagerFactory(String tsPath,
439439
char[] pass) throws GeneralSecurityException, IOException {
440440
TrustManagerFactory tmf;
441-
KeyStore ts = KeyStore.getInstance("JKS");
442441

443-
try (FileInputStream fsIn = new FileInputStream(tsPath)) {
444-
ts.load(fsIn, pass);
445-
tmf = TrustManagerFactory.getInstance("SunX509");
446-
tmf.init(ts);
447-
}
442+
KeyStore ts = KeyStore.getInstance(new File(tsPath), pass);
443+
tmf = TrustManagerFactory.getInstance("SunX509");
444+
tmf.init(ts);
445+
448446
return tmf;
449447
}
450448

@@ -463,13 +461,11 @@ private static TrustManagerFactory makeTrustManagerFactory(String tsPath,
463461
private static KeyManagerFactory makeKeyManagerFactory(String ksPath,
464462
char[] pass) throws GeneralSecurityException, IOException {
465463
KeyManagerFactory kmf;
466-
KeyStore ks = KeyStore.getInstance("JKS");
467464

468-
try (FileInputStream fsIn = new FileInputStream(ksPath)) {
469-
ks.load(fsIn, pass);
470-
kmf = KeyManagerFactory.getInstance("SunX509");
471-
kmf.init(ks, pass);
472-
}
465+
KeyStore ks = KeyStore.getInstance(new File(ksPath), pass);
466+
kmf = KeyManagerFactory.getInstance("SunX509");
467+
kmf.init(ks, pass);
468+
473469
return kmf;
474470
}
475471

‎test/jdk/javax/net/ssl/SSLSession/SSLCtxAccessToSessCtx.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -179,8 +179,8 @@ public static void main(String[] args) throws Exception {
179179

180180
sslctx = SSLContext.getInstance("TLS");
181181
KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
182-
KeyStore ks = KeyStore.getInstance("JKS");
183-
ks.load(new FileInputStream(keyFilename), passwd.toCharArray());
182+
KeyStore ks = KeyStore.getInstance(new File(keyFilename),
183+
passwd.toCharArray());
184184
kmf.init(ks, passwd.toCharArray());
185185
sslctx.init(kmf.getKeyManagers(), null, null);
186186

‎test/jdk/javax/net/ssl/SSLSession/SessionCacheSizeTests.java

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -315,10 +315,9 @@ public static void main(String[] args) throws Exception {
315315

316316
sslctx = SSLContext.getInstance("TLS");
317317
KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
318-
KeyStore ks = KeyStore.getInstance("JKS");
319-
try (FileInputStream fis = new FileInputStream(keyFilename)) {
320-
ks.load(fis, passwd.toCharArray());
321-
}
318+
KeyStore ks = KeyStore.getInstance(new File(keyFilename),
319+
passwd.toCharArray());
320+
322321
kmf.init(ks, passwd.toCharArray());
323322
sslctx.init(kmf.getKeyManagers(), null, null);
324323
sslssf = (SSLServerSocketFactory) sslctx.getServerSocketFactory();

‎test/jdk/javax/net/ssl/SSLSession/SessionTimeOutTests.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -342,8 +342,8 @@ public static void main(String[] args) throws Exception {
342342

343343
sslctx = SSLContext.getInstance("TLS");
344344
KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
345-
KeyStore ks = KeyStore.getInstance("JKS");
346-
ks.load(new FileInputStream(keyFilename), passwd.toCharArray());
345+
KeyStore ks = KeyStore.getInstance(new File(keyFilename),
346+
passwd.toCharArray());
347347
kmf.init(ks, passwd.toCharArray());
348348
sslctx.init(kmf.getKeyManagers(), null, null);
349349
sslssf = (SSLServerSocketFactory) sslctx.getServerSocketFactory();

‎test/jdk/javax/net/ssl/etc/keystore

1.54 KB
Binary file not shown.

‎test/jdk/javax/net/ssl/etc/truststore

533 Bytes
Binary file not shown.
693 Bytes
Binary file not shown.

‎test/jdk/sun/net/www/http/HttpClient/B8025710.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -264,8 +264,8 @@ class HttpServer extends Thread implements Closeable {
264264
HttpServer() throws Exception {
265265
super("HttpServer Thread");
266266

267-
KeyStore ks = KeyStore.getInstance("JKS");
268-
ks.load(new FileInputStream(keystorefile), passphrase.toCharArray());
267+
KeyStore ks = KeyStore.getInstance(new File(keystorefile),
268+
passphrase.toCharArray());
269269
KeyManagerFactory factory = KeyManagerFactory.getInstance("SunX509");
270270
factory.init(ks, passphrase.toCharArray());
271271
SSLContext ctx = SSLContext.getInstance("TLS");

‎test/jdk/sun/security/provider/X509Factory/BadPem.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -28,8 +28,9 @@
2828
* @modules java.base/sun.security.provider
2929
*/
3030

31+
import java.io.ByteArrayInputStream;
3132
import java.io.ByteArrayOutputStream;
32-
import java.io.FileInputStream;
33+
import java.io.File;
3334
import java.io.PrintStream;
3435
import java.security.KeyStore;
3536
import java.security.cert.CertificateException;
@@ -38,7 +39,6 @@
3839

3940
import sun.security.provider.X509Factory;
4041
import java.security.cert.CertificateFactory;
41-
import java.io.ByteArrayInputStream;
4242

4343
public class BadPem {
4444

@@ -49,8 +49,8 @@ public static void main(String[] args) throws Exception {
4949
String alias = "dummy";
5050

5151
CertificateFactory cf = CertificateFactory.getInstance("X.509");
52-
KeyStore keyStore = KeyStore.getInstance("JKS");
53-
keyStore.load(new FileInputStream(ks), pass.toCharArray());
52+
KeyStore keyStore = KeyStore.getInstance(new File(ks),
53+
pass.toCharArray());
5454
byte[] cert = keyStore.getCertificate(alias).getEncoded();
5555

5656
// 8074935

‎test/jdk/sun/security/provider/X509Factory/BigCRL.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,7 @@
2929
* @run main/othervm -Xshare:off -Xmx1024m BigCRL
3030
*/
3131

32+
import java.io.File;
3233
import java.io.FileInputStream;
3334
import java.math.BigInteger;
3435
import java.security.KeyStore;
@@ -49,8 +50,8 @@ public static void main(String[] args) throws Exception {
4950
String pass = "passphrase";
5051
String alias = "dummy";
5152

52-
KeyStore keyStore = KeyStore.getInstance("JKS");
53-
keyStore.load(new FileInputStream(ks), pass.toCharArray());
53+
KeyStore keyStore = KeyStore.getInstance(new File(ks),
54+
pass.toCharArray());
5455
Certificate signerCert = keyStore.getCertificate(alias);
5556
byte[] encoded = signerCert.getEncoded();
5657
X509CertImpl signerCertImpl = new X509CertImpl(encoded);

‎test/jdk/sun/security/ssl/GenSSLConfigs/main.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
/*
10-
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
10+
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
1111
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1212
*
1313
* This code is free software; you can redistribute it and/or modify it
@@ -190,9 +190,8 @@ private static void initContext()
190190
System.setProperty("javax.net.ssl.trustStore", testRoot
191191
+ "/../../../../javax/net/ssl/etc/truststore");
192192

193-
KeyStore ks = KeyStore.getInstance("JKS");
194-
ks.load(new FileInputStream(testRoot
195-
+ "/../../../../javax/net/ssl/etc/truststore"),
193+
KeyStore ks = KeyStore.getInstance(new File(testRoot
194+
+ "/../../../../javax/net/ssl/etc/truststore"),
196195
"passphrase".toCharArray());
197196
KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
198197
kmf.init(ks, "passphrase".toCharArray());

‎test/jdk/sun/security/ssl/InputRecord/ClientHelloRead.java

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -34,7 +34,7 @@
3434
*/
3535

3636
import java.io.BufferedReader;
37-
import java.io.FileInputStream;
37+
import java.io.File;
3838
import java.io.IOException;
3939
import java.io.InputStreamReader;
4040
import java.net.ServerSocket;
@@ -146,10 +146,9 @@ public static void main(String args[]) throws Exception
146146

147147
ctx = SSLContext.getInstance("TLS");
148148
kmf = KeyManagerFactory.getInstance("SunX509");
149-
ks = KeyStore.getInstance("JKS");
149+
ks = KeyStore.getInstance(new File(System.getProperty(
150+
"javax.net.ssl.keyStore")), passphrase);
150151

151-
ks.load(new FileInputStream(System.getProperty(
152-
"javax.net.ssl.keyStore")), passphrase);
153152
kmf.init(ks, passphrase);
154153
ctx.init(kmf.getKeyManagers(), null, null);
155154

‎test/jdk/sun/security/ssl/SSLEngineImpl/TestBadDNForPeerCA.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import javax.net.ssl.SSLEngineResult.HandshakeStatus;
3838
import javax.net.ssl.SSLHandshakeException;
3939
import javax.net.ssl.TrustManagerFactory;
40+
import java.io.File;
4041
import java.io.FileInputStream;
4142
import java.nio.ByteBuffer;
4243
import java.security.KeyStore;
@@ -101,13 +102,10 @@ public static void main(String[] args) throws Exception {
101102

102103
public TestBadDNForPeerCA() throws Exception {
103104

104-
KeyStore ks = KeyStore.getInstance("JKS");
105-
KeyStore ts = KeyStore.getInstance("JKS");
106-
107105
char[] passphrase = passwd.toCharArray();
108106

109-
ks.load(new FileInputStream(keyStoreFile), passphrase);
110-
ts.load(new FileInputStream(keyStoreFile), passphrase);
107+
KeyStore ks = KeyStore.getInstance(new File(keyStoreFile), passphrase);
108+
KeyStore ts = KeyStore.getInstance(new File(keyStoreFile), passphrase);
111109

112110
KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
113111
kmf.init(ks, passphrase);

‎test/jdk/sun/security/ssl/SSLEngineImpl/TestBadDNForPeerCA12.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import javax.net.ssl.SSLEngineResult.HandshakeStatus;
3838
import javax.net.ssl.SSLHandshakeException;
3939
import javax.net.ssl.TrustManagerFactory;
40+
import java.io.File;
4041
import java.io.FileInputStream;
4142
import java.nio.ByteBuffer;
4243
import java.security.KeyStore;
@@ -124,13 +125,10 @@ public static void main(String[] args) throws Exception {
124125

125126
public TestBadDNForPeerCA12() throws Exception {
126127

127-
KeyStore ks = KeyStore.getInstance("JKS");
128-
KeyStore ts = KeyStore.getInstance("JKS");
129-
130128
char[] passphrase = passwd.toCharArray();
131129

132-
ks.load(new FileInputStream(keyStoreFile), passphrase);
133-
ts.load(new FileInputStream(keyStoreFile), passphrase);
130+
KeyStore ks = KeyStore.getInstance(new File(keyStoreFile), passphrase);
131+
KeyStore ts = KeyStore.getInstance(new File(keyStoreFile), passphrase);
134132

135133
KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
136134
kmf.init(ks, passphrase);

‎test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketSSLEngineCloseInbound.java

+3-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -173,16 +173,10 @@ public static void main(String[] args) throws Exception {
173173
*/
174174
public SSLSocketSSLEngineCloseInbound(String protocol) throws Exception {
175175

176-
KeyStore ks = KeyStore.getInstance("JKS");
177-
KeyStore ts = KeyStore.getInstance("JKS");
178-
179176
char[] passphrase = "passphrase".toCharArray();
180177

181-
try (FileInputStream keyFile = new FileInputStream(keyFilename);
182-
FileInputStream trustFile = new FileInputStream(trustFilename)) {
183-
ks.load(keyFile, passphrase);
184-
ts.load(trustFile, passphrase);
185-
}
178+
KeyStore ks = KeyStore.getInstance(new File(keyFilename), passphrase);
179+
KeyStore ts = KeyStore.getInstance(new File(trustFilename), passphrase);
186180

187181
KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
188182
kmf.init(ks, passphrase);

‎test/jdk/sun/security/ssl/ServerHandshaker/GetPeerHost.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -41,6 +41,8 @@ public static void main(String[] argv) throws Exception {
4141
String testRoot = System.getProperty("test.src", ".");
4242
System.setProperty("javax.net.ssl.trustStore", testRoot
4343
+ "/../../../../javax/net/ssl/etc/truststore");
44+
System.setProperty("javax.net.ssl.trustStoreType", "PKCS12");
45+
System.setProperty("javax.net.ssl.trustStorePassword", "passphrase");
4446
GetPeerHostServer server = new GetPeerHostServer();
4547
server.start();
4648
GetPeerHostClient client =

‎test/jdk/sun/security/ssl/ServerHandshaker/GetPeerHostServer.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -49,12 +49,10 @@ public GetPeerHostServer ()
4949
try {
5050
SSLContext ctx = SSLContext.getInstance("TLS");
5151
KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
52-
KeyStore ks = KeyStore.getInstance("JKS");
5352
char[] passphrase = "passphrase".toCharArray();
5453
String testRoot = System.getProperty("test.src", ".");
55-
ks.load(new FileInputStream(testRoot
56-
+ "/../../../../javax/net/ssl/etc/keystore"),
57-
passphrase);
54+
KeyStore ks = KeyStore.getInstance(new File(testRoot
55+
+ "/../../../../javax/net/ssl/etc/keystore"), passphrase);
5856
kmf.init(ks, passphrase);
5957
ctx.init(kmf.getKeyManagers(), null, null);
6058
ServerSocketFactory ssf = ctx.getServerSocketFactory();

‎test/jdk/sun/security/ssl/ServerHandshaker/HelloExtensionsTest.java

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -254,13 +254,10 @@ static private SSLEngine createSSLEngine(String keyFile, String trustFile)
254254

255255
SSLEngine ssle;
256256

257-
KeyStore ks = KeyStore.getInstance("JKS");
258-
KeyStore ts = KeyStore.getInstance("JKS");
259-
260257
char[] passphrase = "passphrase".toCharArray();
261258

262-
ks.load(new FileInputStream(keyFile), passphrase);
263-
ts.load(new FileInputStream(trustFile), passphrase);
259+
KeyStore ks = KeyStore.getInstance(new File(keyFile), passphrase);
260+
KeyStore ts = KeyStore.getInstance(new File(trustFile), passphrase);
264261

265262
KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
266263
kmf.init(ks, passphrase);

‎test/jdk/sun/security/ssl/X509KeyManager/PreferredKey.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -71,8 +71,7 @@ public static void main(String[] args) throws Exception {
7171
"/" + keyStoreFile;
7272
char [] password = passwd.toCharArray();
7373

74-
ks = KeyStore.getInstance("JKS");
75-
ks.load(new FileInputStream(keyFilename), password);
74+
ks = KeyStore.getInstance(new File(keyFilename), password);
7675
kmf = KeyManagerFactory.getInstance("NewSunX509");
7776
kmf.init(ks, password);
7877
km = (X509KeyManager) kmf.getKeyManagers()[0];

‎test/jdk/sun/security/ssl/X509KeyManager/SelectOneKeyOutOfMany.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -70,8 +70,7 @@ public static void main(String[] args) throws Exception {
7070
* Setup the tests.
7171
*/
7272
kmf = KeyManagerFactory.getInstance("SunX509");
73-
ks = KeyStore.getInstance("JKS");
74-
ks.load(new FileInputStream(keyFilename), passphrase);
73+
ks = KeyStore.getInstance(new File(keyFilename), passphrase);
7574
kmf.init(ks, passphrase);
7675
km = (X509KeyManager) kmf.getKeyManagers()[0];
7776

‎test/jdk/sun/security/ssl/X509TrustManagerImpl/CertRequestOverflow.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -192,13 +192,11 @@ private SSLContext getContext(boolean server) throws Exception {
192192
"/" + trustStoreFile;
193193

194194
KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
195-
KeyStore ks = KeyStore.getInstance("JKS");
196-
ks.load(new FileInputStream(keyFilename), cpasswd);
195+
KeyStore ks = KeyStore.getInstance(new File(keyFilename), cpasswd);
197196
kmf.init(ks, cpasswd);
198197

199198
TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
200-
KeyStore ts = KeyStore.getInstance("JKS");
201-
ts.load(new FileInputStream(trustFilename), cpasswd);
199+
KeyStore ts = KeyStore.getInstance(new File(trustFilename), cpasswd);
202200
tmf.init(ts);
203201

204202
TrustManager tms[] = tmf.getTrustManagers();

‎test/jdk/sun/security/ssl/X509TrustManagerImpl/CheckNullEntity.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -65,8 +65,7 @@ private void initialize() throws Exception {
6565
"/" + trustStoreFile;
6666
char[] passphrase = "passphrase".toCharArray();
6767

68-
KeyStore ks = KeyStore.getInstance("JKS");
69-
ks.load(new FileInputStream(trustFilename), passphrase);
68+
KeyStore ks = KeyStore.getInstance(new File(trustFilename), passphrase);
7069

7170
for (Enumeration e = ks.aliases() ; e.hasMoreElements() ;) {
7271
String alias = (String)e.nextElement();

‎test/jdk/sun/security/ssl/X509TrustManagerImpl/X509ExtendedTMEnabled.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2010, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -181,13 +181,11 @@ private SSLContext getContext(boolean server) throws Exception {
181181
"/" + trustStoreFile;
182182

183183
KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
184-
KeyStore ks = KeyStore.getInstance("JKS");
185-
ks.load(new FileInputStream(keyFilename), cpasswd);
184+
KeyStore ks = KeyStore.getInstance(new File(keyFilename), cpasswd);
186185
kmf.init(ks, cpasswd);
187186

188187
TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
189-
KeyStore ts = KeyStore.getInstance("JKS");
190-
ts.load(new FileInputStream(trustFilename), cpasswd);
188+
KeyStore ts = KeyStore.getInstance(new File(trustFilename), cpasswd);
191189
tmf.init(ts);
192190

193191
TrustManager tms[] = tmf.getTrustManagers();

0 commit comments

Comments
 (0)
Please sign in to comment.