author | erikj |
Tue, 12 Sep 2017 19:03:39 +0200 | |
changeset 47216 | 71c04702a3d5 |
parent 43701 | jdk/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java@fe8c324ba97c |
child 50768 | 68fa3d4026ea |
child 56542 | 56aaa6cb3693 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
43701
fe8c324ba97c
8160655: Fix denyAfter and usage types for security properties
ascarpino
parents:
43009
diff
changeset
|
2 |
* Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package sun.security.ssl; |
|
27 |
||
28 |
import java.net.Socket; |
|
29 |
||
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
30 |
import java.io.*; |
7043 | 31 |
import java.util.*; |
2 | 32 |
import java.security.*; |
33 |
import java.security.cert.*; |
|
7043 | 34 |
import java.security.cert.Certificate; |
2 | 35 |
|
36 |
import javax.net.ssl.*; |
|
37 |
||
7043 | 38 |
import sun.security.provider.certpath.AlgorithmChecker; |
22068 | 39 |
import sun.security.action.GetPropertyAction; |
43701
fe8c324ba97c
8160655: Fix denyAfter and usage types for security properties
ascarpino
parents:
43009
diff
changeset
|
40 |
import sun.security.validator.Validator; |
7043 | 41 |
|
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
42 |
public abstract class SSLContextImpl extends SSLContextSpi { |
2 | 43 |
|
44 |
private static final Debug debug = Debug.getInstance("ssl"); |
|
45 |
||
46 |
private final EphemeralKeyManager ephemeralKeyManager; |
|
47 |
private final SSLSessionContextImpl clientCache; |
|
48 |
private final SSLSessionContextImpl serverCache; |
|
49 |
||
50 |
private boolean isInitialized; |
|
51 |
||
52 |
private X509ExtendedKeyManager keyManager; |
|
53 |
private X509TrustManager trustManager; |
|
54 |
private SecureRandom secureRandom; |
|
55 |
||
30904 | 56 |
// DTLS cookie exchange manager |
34826 | 57 |
private volatile HelloCookieManager helloCookieManager; |
30904 | 58 |
|
36132
c99a60377145
8145854: SSLContextImpl.statusResponseManager should be generated if required
jnimeh
parents:
34826
diff
changeset
|
59 |
private final boolean clientEnableStapling = Debug.getBooleanProperty( |
c99a60377145
8145854: SSLContextImpl.statusResponseManager should be generated if required
jnimeh
parents:
34826
diff
changeset
|
60 |
"jdk.tls.client.enableStatusRequestExtension", true); |
c99a60377145
8145854: SSLContextImpl.statusResponseManager should be generated if required
jnimeh
parents:
34826
diff
changeset
|
61 |
private final boolean serverEnableStapling = Debug.getBooleanProperty( |
c99a60377145
8145854: SSLContextImpl.statusResponseManager should be generated if required
jnimeh
parents:
34826
diff
changeset
|
62 |
"jdk.tls.server.enableStatusRequestExtension", false); |
40275
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
63 |
private final static Collection<CipherSuite> clientCustomizedCipherSuites = |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
64 |
getCustomizedCipherSuites("jdk.tls.client.cipherSuites"); |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
65 |
private final static Collection<CipherSuite> serverCustomizedCipherSuites = |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
66 |
getCustomizedCipherSuites("jdk.tls.server.cipherSuites"); |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
67 |
|
36132
c99a60377145
8145854: SSLContextImpl.statusResponseManager should be generated if required
jnimeh
parents:
34826
diff
changeset
|
68 |
private volatile StatusResponseManager statusResponseManager; |
32032 | 69 |
|
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
70 |
SSLContextImpl() { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
71 |
ephemeralKeyManager = new EphemeralKeyManager(); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
72 |
clientCache = new SSLSessionContextImpl(); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
73 |
serverCache = new SSLSessionContextImpl(); |
2 | 74 |
} |
75 |
||
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
13815
diff
changeset
|
76 |
@Override |
2 | 77 |
protected void engineInit(KeyManager[] km, TrustManager[] tm, |
78 |
SecureRandom sr) throws KeyManagementException { |
|
79 |
isInitialized = false; |
|
80 |
keyManager = chooseKeyManager(km); |
|
81 |
||
82 |
if (tm == null) { |
|
83 |
try { |
|
84 |
TrustManagerFactory tmf = TrustManagerFactory.getInstance( |
|
85 |
TrustManagerFactory.getDefaultAlgorithm()); |
|
86 |
tmf.init((KeyStore)null); |
|
87 |
tm = tmf.getTrustManagers(); |
|
88 |
} catch (Exception e) { |
|
89 |
// eat |
|
90 |
} |
|
91 |
} |
|
92 |
trustManager = chooseTrustManager(tm); |
|
93 |
||
94 |
if (sr == null) { |
|
95 |
secureRandom = JsseJce.getSecureRandom(); |
|
96 |
} else { |
|
7043 | 97 |
if (SunJSSE.isFIPS() && |
98 |
(sr.getProvider() != SunJSSE.cryptoProvider)) { |
|
2 | 99 |
throw new KeyManagementException |
100 |
("FIPS mode: SecureRandom must be from provider " |
|
101 |
+ SunJSSE.cryptoProvider.getName()); |
|
102 |
} |
|
103 |
secureRandom = sr; |
|
104 |
} |
|
105 |
||
106 |
/* |
|
107 |
* The initial delay of seeding the random number generator |
|
108 |
* could be long enough to cause the initial handshake on our |
|
109 |
* first connection to timeout and fail. Make sure it is |
|
110 |
* primed and ready by getting some initial output from it. |
|
111 |
*/ |
|
112 |
if (debug != null && Debug.isOn("sslctx")) { |
|
113 |
System.out.println("trigger seeding of SecureRandom"); |
|
114 |
} |
|
115 |
secureRandom.nextInt(); |
|
116 |
if (debug != null && Debug.isOn("sslctx")) { |
|
117 |
System.out.println("done seeding SecureRandom"); |
|
118 |
} |
|
34826 | 119 |
|
2 | 120 |
isInitialized = true; |
121 |
} |
|
122 |
||
123 |
private X509TrustManager chooseTrustManager(TrustManager[] tm) |
|
124 |
throws KeyManagementException { |
|
125 |
// We only use the first instance of X509TrustManager passed to us. |
|
126 |
for (int i = 0; tm != null && i < tm.length; i++) { |
|
127 |
if (tm[i] instanceof X509TrustManager) { |
|
7043 | 128 |
if (SunJSSE.isFIPS() && |
129 |
!(tm[i] instanceof X509TrustManagerImpl)) { |
|
2 | 130 |
throw new KeyManagementException |
131 |
("FIPS mode: only SunJSSE TrustManagers may be used"); |
|
132 |
} |
|
7043 | 133 |
|
134 |
if (tm[i] instanceof X509ExtendedTrustManager) { |
|
135 |
return (X509TrustManager)tm[i]; |
|
136 |
} else { |
|
137 |
return new AbstractTrustManagerWrapper( |
|
138 |
(X509TrustManager)tm[i]); |
|
139 |
} |
|
2 | 140 |
} |
141 |
} |
|
142 |
||
143 |
// nothing found, return a dummy X509TrustManager. |
|
144 |
return DummyX509TrustManager.INSTANCE; |
|
145 |
} |
|
146 |
||
147 |
private X509ExtendedKeyManager chooseKeyManager(KeyManager[] kms) |
|
148 |
throws KeyManagementException { |
|
149 |
for (int i = 0; kms != null && i < kms.length; i++) { |
|
150 |
KeyManager km = kms[i]; |
|
12874 | 151 |
if (!(km instanceof X509KeyManager)) { |
2 | 152 |
continue; |
153 |
} |
|
154 |
if (SunJSSE.isFIPS()) { |
|
155 |
// In FIPS mode, require that one of SunJSSE's own keymanagers |
|
156 |
// is used. Otherwise, we cannot be sure that only keys from |
|
157 |
// the FIPS token are used. |
|
158 |
if ((km instanceof X509KeyManagerImpl) |
|
159 |
|| (km instanceof SunX509KeyManagerImpl)) { |
|
160 |
return (X509ExtendedKeyManager)km; |
|
161 |
} else { |
|
162 |
// throw exception, we don't want to silently use the |
|
163 |
// dummy keymanager without telling the user. |
|
164 |
throw new KeyManagementException |
|
165 |
("FIPS mode: only SunJSSE KeyManagers may be used"); |
|
166 |
} |
|
167 |
} |
|
168 |
if (km instanceof X509ExtendedKeyManager) { |
|
169 |
return (X509ExtendedKeyManager)km; |
|
170 |
} |
|
171 |
if (debug != null && Debug.isOn("sslctx")) { |
|
172 |
System.out.println( |
|
173 |
"X509KeyManager passed to " + |
|
174 |
"SSLContext.init(): need an " + |
|
175 |
"X509ExtendedKeyManager for SSLEngine use"); |
|
176 |
} |
|
7043 | 177 |
return new AbstractKeyManagerWrapper((X509KeyManager)km); |
2 | 178 |
} |
179 |
||
180 |
// nothing found, return a dummy X509ExtendedKeyManager |
|
181 |
return DummyX509KeyManager.INSTANCE; |
|
182 |
} |
|
183 |
||
30904 | 184 |
abstract SSLEngine createSSLEngineImpl(); |
185 |
abstract SSLEngine createSSLEngineImpl(String host, int port); |
|
186 |
||
187 |
@Override |
|
188 |
protected SSLEngine engineCreateSSLEngine() { |
|
189 |
if (!isInitialized) { |
|
190 |
throw new IllegalStateException("SSLContext is not initialized"); |
|
191 |
} |
|
192 |
return createSSLEngineImpl(); |
|
193 |
} |
|
194 |
||
195 |
@Override |
|
196 |
protected SSLEngine engineCreateSSLEngine(String host, int port) { |
|
197 |
if (!isInitialized) { |
|
198 |
throw new IllegalStateException("SSLContext is not initialized"); |
|
199 |
} |
|
200 |
return createSSLEngineImpl(host, port); |
|
201 |
} |
|
202 |
||
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
13815
diff
changeset
|
203 |
@Override |
2 | 204 |
protected SSLSocketFactory engineGetSocketFactory() { |
205 |
if (!isInitialized) { |
|
30904 | 206 |
throw new IllegalStateException("SSLContext is not initialized"); |
2 | 207 |
} |
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
208 |
return new SSLSocketFactoryImpl(this); |
2 | 209 |
} |
210 |
||
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
13815
diff
changeset
|
211 |
@Override |
2 | 212 |
protected SSLServerSocketFactory engineGetServerSocketFactory() { |
213 |
if (!isInitialized) { |
|
214 |
throw new IllegalStateException("SSLContext is not initialized"); |
|
215 |
} |
|
216 |
return new SSLServerSocketFactoryImpl(this); |
|
217 |
} |
|
218 |
||
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
13815
diff
changeset
|
219 |
@Override |
2 | 220 |
protected SSLSessionContext engineGetClientSessionContext() { |
221 |
return clientCache; |
|
222 |
} |
|
223 |
||
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
13815
diff
changeset
|
224 |
@Override |
2 | 225 |
protected SSLSessionContext engineGetServerSessionContext() { |
226 |
return serverCache; |
|
227 |
} |
|
228 |
||
229 |
SecureRandom getSecureRandom() { |
|
230 |
return secureRandom; |
|
231 |
} |
|
232 |
||
233 |
X509ExtendedKeyManager getX509KeyManager() { |
|
234 |
return keyManager; |
|
235 |
} |
|
236 |
||
237 |
X509TrustManager getX509TrustManager() { |
|
238 |
return trustManager; |
|
239 |
} |
|
240 |
||
241 |
EphemeralKeyManager getEphemeralKeyManager() { |
|
242 |
return ephemeralKeyManager; |
|
243 |
} |
|
244 |
||
34826 | 245 |
// Used for DTLS in server mode only, see ServerHandshaker. |
30904 | 246 |
HelloCookieManager getHelloCookieManager() { |
247 |
if (!isInitialized) { |
|
248 |
throw new IllegalStateException("SSLContext is not initialized"); |
|
249 |
} |
|
250 |
||
34826 | 251 |
if (helloCookieManager != null) { |
252 |
return helloCookieManager; |
|
253 |
} |
|
254 |
||
255 |
synchronized (this) { |
|
256 |
if (helloCookieManager == null) { |
|
257 |
helloCookieManager = getHelloCookieManager(secureRandom); |
|
258 |
} |
|
30904 | 259 |
} |
260 |
||
261 |
return helloCookieManager; |
|
262 |
} |
|
263 |
||
264 |
HelloCookieManager getHelloCookieManager(SecureRandom secureRandom) { |
|
265 |
throw new UnsupportedOperationException( |
|
266 |
"Cookie exchange applies to DTLS only"); |
|
267 |
} |
|
268 |
||
32032 | 269 |
StatusResponseManager getStatusResponseManager() { |
36132
c99a60377145
8145854: SSLContextImpl.statusResponseManager should be generated if required
jnimeh
parents:
34826
diff
changeset
|
270 |
if (serverEnableStapling && statusResponseManager == null) { |
c99a60377145
8145854: SSLContextImpl.statusResponseManager should be generated if required
jnimeh
parents:
34826
diff
changeset
|
271 |
synchronized (this) { |
c99a60377145
8145854: SSLContextImpl.statusResponseManager should be generated if required
jnimeh
parents:
34826
diff
changeset
|
272 |
if (statusResponseManager == null) { |
c99a60377145
8145854: SSLContextImpl.statusResponseManager should be generated if required
jnimeh
parents:
34826
diff
changeset
|
273 |
if (debug != null && Debug.isOn("sslctx")) { |
c99a60377145
8145854: SSLContextImpl.statusResponseManager should be generated if required
jnimeh
parents:
34826
diff
changeset
|
274 |
System.out.println( |
c99a60377145
8145854: SSLContextImpl.statusResponseManager should be generated if required
jnimeh
parents:
34826
diff
changeset
|
275 |
"Initializing StatusResponseManager"); |
c99a60377145
8145854: SSLContextImpl.statusResponseManager should be generated if required
jnimeh
parents:
34826
diff
changeset
|
276 |
} |
c99a60377145
8145854: SSLContextImpl.statusResponseManager should be generated if required
jnimeh
parents:
34826
diff
changeset
|
277 |
statusResponseManager = new StatusResponseManager(); |
c99a60377145
8145854: SSLContextImpl.statusResponseManager should be generated if required
jnimeh
parents:
34826
diff
changeset
|
278 |
} |
c99a60377145
8145854: SSLContextImpl.statusResponseManager should be generated if required
jnimeh
parents:
34826
diff
changeset
|
279 |
} |
c99a60377145
8145854: SSLContextImpl.statusResponseManager should be generated if required
jnimeh
parents:
34826
diff
changeset
|
280 |
} |
c99a60377145
8145854: SSLContextImpl.statusResponseManager should be generated if required
jnimeh
parents:
34826
diff
changeset
|
281 |
|
32032 | 282 |
return statusResponseManager; |
283 |
} |
|
284 |
||
34826 | 285 |
// Get supported ProtocolList. |
286 |
abstract ProtocolList getSuportedProtocolList(); |
|
287 |
||
288 |
// Get default ProtocolList for server mode. |
|
289 |
abstract ProtocolList getServerDefaultProtocolList(); |
|
290 |
||
291 |
// Get default ProtocolList for client mode. |
|
292 |
abstract ProtocolList getClientDefaultProtocolList(); |
|
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
293 |
|
34826 | 294 |
// Get supported CipherSuiteList. |
295 |
abstract CipherSuiteList getSupportedCipherSuiteList(); |
|
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
296 |
|
34826 | 297 |
// Get default CipherSuiteList for server mode. |
298 |
abstract CipherSuiteList getServerDefaultCipherSuiteList(); |
|
299 |
||
300 |
// Get default CipherSuiteList for client mode. |
|
301 |
abstract CipherSuiteList getClientDefaultCipherSuiteList(); |
|
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
302 |
|
21278 | 303 |
// Get default ProtocolList. |
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
304 |
ProtocolList getDefaultProtocolList(boolean roleIsServer) { |
34826 | 305 |
return roleIsServer ? getServerDefaultProtocolList() |
306 |
: getClientDefaultProtocolList(); |
|
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
307 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
308 |
|
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
309 |
// Get default CipherSuiteList. |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
310 |
CipherSuiteList getDefaultCipherSuiteList(boolean roleIsServer) { |
34826 | 311 |
return roleIsServer ? getServerDefaultCipherSuiteList() |
312 |
: getClientDefaultCipherSuiteList(); |
|
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
313 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
314 |
|
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
315 |
/** |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
316 |
* Return whether a protocol list is the original default enabled |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
317 |
* protocols. See: SSLSocket/SSLEngine.setEnabledProtocols() |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
318 |
*/ |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
319 |
boolean isDefaultProtocolList(ProtocolList protocols) { |
34826 | 320 |
return (protocols == getServerDefaultProtocolList()) || |
321 |
(protocols == getClientDefaultProtocolList()); |
|
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
322 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
323 |
|
30904 | 324 |
/** |
325 |
* Return whether a protocol list is the original default enabled |
|
326 |
* protocols. See: SSLSocket/SSLEngine.setEnabledProtocols() |
|
327 |
*/ |
|
328 |
boolean isDefaultCipherSuiteList(CipherSuiteList cipherSuites) { |
|
34826 | 329 |
return (cipherSuites == getServerDefaultCipherSuiteList()) || |
330 |
(cipherSuites == getClientDefaultCipherSuiteList()); |
|
30904 | 331 |
} |
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
332 |
|
36132
c99a60377145
8145854: SSLContextImpl.statusResponseManager should be generated if required
jnimeh
parents:
34826
diff
changeset
|
333 |
/** |
c99a60377145
8145854: SSLContextImpl.statusResponseManager should be generated if required
jnimeh
parents:
34826
diff
changeset
|
334 |
* Return whether client or server side stapling has been enabled |
c99a60377145
8145854: SSLContextImpl.statusResponseManager should be generated if required
jnimeh
parents:
34826
diff
changeset
|
335 |
* for this SSLContextImpl |
c99a60377145
8145854: SSLContextImpl.statusResponseManager should be generated if required
jnimeh
parents:
34826
diff
changeset
|
336 |
* @param isClient true if the caller is operating in a client side role, |
c99a60377145
8145854: SSLContextImpl.statusResponseManager should be generated if required
jnimeh
parents:
34826
diff
changeset
|
337 |
* false if acting as a server. |
c99a60377145
8145854: SSLContextImpl.statusResponseManager should be generated if required
jnimeh
parents:
34826
diff
changeset
|
338 |
* @return true if stapling has been enabled for the specified role, false |
c99a60377145
8145854: SSLContextImpl.statusResponseManager should be generated if required
jnimeh
parents:
34826
diff
changeset
|
339 |
* otherwise. |
c99a60377145
8145854: SSLContextImpl.statusResponseManager should be generated if required
jnimeh
parents:
34826
diff
changeset
|
340 |
*/ |
c99a60377145
8145854: SSLContextImpl.statusResponseManager should be generated if required
jnimeh
parents:
34826
diff
changeset
|
341 |
boolean isStaplingEnabled(boolean isClient) { |
c99a60377145
8145854: SSLContextImpl.statusResponseManager should be generated if required
jnimeh
parents:
34826
diff
changeset
|
342 |
return isClient ? clientEnableStapling : serverEnableStapling; |
c99a60377145
8145854: SSLContextImpl.statusResponseManager should be generated if required
jnimeh
parents:
34826
diff
changeset
|
343 |
} |
c99a60377145
8145854: SSLContextImpl.statusResponseManager should be generated if required
jnimeh
parents:
34826
diff
changeset
|
344 |
|
40275
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
345 |
|
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
346 |
/* |
40275
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
347 |
* Return the list of all available CipherSuites that are supported |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
348 |
* using currently installed providers. |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
349 |
*/ |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
350 |
private static CipherSuiteList getApplicableSupportedCipherSuiteList( |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
351 |
ProtocolList protocols) { |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
352 |
|
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
353 |
return getApplicableCipherSuiteList( |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
354 |
CipherSuite.allowedCipherSuites(), |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
355 |
protocols, CipherSuite.SUPPORTED_SUITES_PRIORITY); |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
356 |
} |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
357 |
|
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
358 |
/* |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
359 |
* Return the list of all available CipherSuites that are default enabled |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
360 |
* in client or server side. |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
361 |
*/ |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
362 |
private static CipherSuiteList getApplicableEnabledCipherSuiteList( |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
363 |
ProtocolList protocols, boolean isClient) { |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
364 |
|
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
365 |
if (isClient) { |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
366 |
if (!clientCustomizedCipherSuites.isEmpty()) { |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
367 |
return getApplicableCipherSuiteList( |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
368 |
clientCustomizedCipherSuites, |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
369 |
protocols, CipherSuite.SUPPORTED_SUITES_PRIORITY); |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
370 |
} |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
371 |
} else { |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
372 |
if (!serverCustomizedCipherSuites.isEmpty()) { |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
373 |
return getApplicableCipherSuiteList( |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
374 |
serverCustomizedCipherSuites, |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
375 |
protocols, CipherSuite.SUPPORTED_SUITES_PRIORITY); |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
376 |
} |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
377 |
} |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
378 |
|
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
379 |
return getApplicableCipherSuiteList( |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
380 |
CipherSuite.allowedCipherSuites(), |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
381 |
protocols, CipherSuite.DEFAULT_SUITES_PRIORITY); |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
382 |
} |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
383 |
|
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
384 |
/* |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
385 |
* Return the list of available CipherSuites which are applicable to |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
386 |
* the specified protocols. |
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
387 |
*/ |
30904 | 388 |
private static CipherSuiteList getApplicableCipherSuiteList( |
40275
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
389 |
Collection<CipherSuite> allowedCipherSuites, |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
390 |
ProtocolList protocols, int minPriority) { |
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
391 |
|
12874 | 392 |
TreeSet<CipherSuite> suites = new TreeSet<>(); |
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
393 |
if (!(protocols.collection().isEmpty()) && |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
394 |
protocols.min.v != ProtocolVersion.NONE.v) { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
395 |
for (CipherSuite suite : allowedCipherSuites) { |
12874 | 396 |
if (!suite.allowed || suite.priority < minPriority) { |
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
397 |
continue; |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
398 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
399 |
|
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
400 |
if (suite.isAvailable() && |
30904 | 401 |
!protocols.min.obsoletes(suite) && |
402 |
protocols.max.supports(suite)) { |
|
28555 | 403 |
if (SSLAlgorithmConstraints.DEFAULT.permits( |
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
404 |
EnumSet.of(CryptoPrimitive.KEY_AGREEMENT), |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
405 |
suite.name, null)) { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
406 |
suites.add(suite); |
42221
6bd0eb3735b8
8170035: When determining the ciphersuite lists, there is no debug output for disabled suites.
jnimeh
parents:
40700
diff
changeset
|
407 |
} else { |
6bd0eb3735b8
8170035: When determining the ciphersuite lists, there is no debug output for disabled suites.
jnimeh
parents:
40700
diff
changeset
|
408 |
if (debug != null && Debug.isOn("sslctx") && |
6bd0eb3735b8
8170035: When determining the ciphersuite lists, there is no debug output for disabled suites.
jnimeh
parents:
40700
diff
changeset
|
409 |
Debug.isOn("verbose")) { |
6bd0eb3735b8
8170035: When determining the ciphersuite lists, there is no debug output for disabled suites.
jnimeh
parents:
40700
diff
changeset
|
410 |
System.out.println( |
6bd0eb3735b8
8170035: When determining the ciphersuite lists, there is no debug output for disabled suites.
jnimeh
parents:
40700
diff
changeset
|
411 |
"Ignoring disabled cipher suite: " + |
6bd0eb3735b8
8170035: When determining the ciphersuite lists, there is no debug output for disabled suites.
jnimeh
parents:
40700
diff
changeset
|
412 |
suite.name); |
6bd0eb3735b8
8170035: When determining the ciphersuite lists, there is no debug output for disabled suites.
jnimeh
parents:
40700
diff
changeset
|
413 |
} |
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
414 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
415 |
} else if (debug != null && |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
416 |
Debug.isOn("sslctx") && Debug.isOn("verbose")) { |
30904 | 417 |
if (protocols.min.obsoletes(suite)) { |
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
418 |
System.out.println( |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
419 |
"Ignoring obsoleted cipher suite: " + suite); |
30904 | 420 |
} else if (!protocols.max.supports(suite)) { |
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
421 |
System.out.println( |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
422 |
"Ignoring unsupported cipher suite: " + suite); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
423 |
} else { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
424 |
System.out.println( |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
425 |
"Ignoring unavailable cipher suite: " + suite); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
426 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
427 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
428 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
429 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
430 |
|
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
431 |
return new CipherSuiteList(suites); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
432 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
433 |
|
40275
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
434 |
/* |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
435 |
* Get the customized cipher suites specified by the given system property. |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
436 |
*/ |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
437 |
private static Collection<CipherSuite> getCustomizedCipherSuites( |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
438 |
String propertyName) { |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
439 |
|
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
440 |
String property = GetPropertyAction.privilegedGetProperty(propertyName); |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
441 |
if (debug != null && Debug.isOn("sslctx")) { |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
442 |
System.out.println( |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
443 |
"System property " + propertyName + " is set to '" + |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
444 |
property + "'"); |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
445 |
} |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
446 |
if (property != null && property.length() != 0) { |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
447 |
// remove double quote marks from beginning/end of the property |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
448 |
if (property.length() > 1 && property.charAt(0) == '"' && |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
449 |
property.charAt(property.length() - 1) == '"') { |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
450 |
property = property.substring(1, property.length() - 1); |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
451 |
} |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
452 |
} |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
453 |
|
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
454 |
if (property != null && property.length() != 0) { |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
455 |
String[] cipherSuiteNames = property.split(","); |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
456 |
Collection<CipherSuite> cipherSuites = |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
457 |
new ArrayList<>(cipherSuiteNames.length); |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
458 |
for (int i = 0; i < cipherSuiteNames.length; i++) { |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
459 |
cipherSuiteNames[i] = cipherSuiteNames[i].trim(); |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
460 |
if (cipherSuiteNames[i].isEmpty()) { |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
461 |
continue; |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
462 |
} |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
463 |
|
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
464 |
CipherSuite suite; |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
465 |
try { |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
466 |
suite = CipherSuite.valueOf(cipherSuiteNames[i]); |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
467 |
} catch (IllegalArgumentException iae) { |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
468 |
if (debug != null && Debug.isOn("sslctx")) { |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
469 |
System.out.println( |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
470 |
"Unknown or unsupported cipher suite name: " + |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
471 |
cipherSuiteNames[i]); |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
472 |
} |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
473 |
|
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
474 |
continue; |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
475 |
} |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
476 |
|
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
477 |
if (suite.isAvailable()) { |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
478 |
cipherSuites.add(suite); |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
479 |
} else { |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
480 |
if (debug != null && Debug.isOn("sslctx")) { |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
481 |
System.out.println( |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
482 |
"The current installed providers do not " + |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
483 |
"support cipher suite: " + cipherSuiteNames[i]); |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
484 |
} |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
485 |
} |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
486 |
} |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
487 |
|
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
488 |
return cipherSuites; |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
489 |
} |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
490 |
|
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
491 |
return Collections.emptyList(); |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
492 |
} |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
493 |
|
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
494 |
|
30904 | 495 |
private static String[] getAvailableProtocols( |
496 |
ProtocolVersion[] protocolCandidates) { |
|
497 |
||
498 |
List<String> availableProtocols = Collections.<String>emptyList(); |
|
499 |
if (protocolCandidates != null && protocolCandidates.length != 0) { |
|
500 |
availableProtocols = new ArrayList<>(protocolCandidates.length); |
|
501 |
for (ProtocolVersion p : protocolCandidates) { |
|
502 |
if (ProtocolVersion.availableProtocols.contains(p)) { |
|
503 |
availableProtocols.add(p.name); |
|
504 |
} |
|
505 |
} |
|
506 |
} |
|
507 |
||
508 |
return availableProtocols.toArray(new String[0]); |
|
509 |
} |
|
510 |
||
511 |
||
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
512 |
/* |
30904 | 513 |
* The SSLContext implementation for SSL/(D)TLS algorithm |
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
514 |
* |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
515 |
* SSL/TLS protocols specify the forward compatibility and version |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
516 |
* roll-back attack protections, however, a number of SSL/TLS server |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
517 |
* vendors did not implement these aspects properly, and some current |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
518 |
* SSL/TLS servers may refuse to talk to a TLS 1.1 or later client. |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
519 |
* |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
520 |
* Considering above interoperability issues, SunJSSE will not set |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
521 |
* TLS 1.1 and TLS 1.2 as the enabled protocols for client by default. |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
522 |
* |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
523 |
* For SSL/TLS servers, there is no such interoperability issues as |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
524 |
* SSL/TLS clients. In SunJSSE, TLS 1.1 or later version will be the |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
525 |
* enabled protocols for server by default. |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
526 |
* |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
527 |
* We may change the behavior when popular TLS/SSL vendors support TLS |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
528 |
* forward compatibility properly. |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
529 |
* |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
530 |
* SSLv2Hello is no longer necessary. This interoperability option was |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
531 |
* put in place in the late 90's when SSLv3/TLS1.0 were relatively new |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
532 |
* and there were a fair number of SSLv2-only servers deployed. Because |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
533 |
* of the security issues in SSLv2, it is rarely (if ever) used, as |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
534 |
* deployments should now be using SSLv3 and TLSv1. |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
535 |
* |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
536 |
* Considering the issues of SSLv2Hello, we should not enable SSLv2Hello |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
537 |
* by default. Applications still can use it by enabling SSLv2Hello with |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
538 |
* the series of setEnabledProtocols APIs. |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
539 |
*/ |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
540 |
|
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
541 |
/* |
30904 | 542 |
* The base abstract SSLContext implementation for the Transport Layer |
543 |
* Security (TLS) protocols. |
|
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
544 |
* |
22068 | 545 |
* This abstract class encapsulates supported and the default server |
30904 | 546 |
* SSL/TLS parameters. |
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
547 |
* |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
548 |
* @see SSLContext |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
549 |
*/ |
30904 | 550 |
private abstract static class AbstractTLSContext extends SSLContextImpl { |
34826 | 551 |
private static final ProtocolList supportedProtocolList; |
552 |
private static final ProtocolList serverDefaultProtocolList; |
|
553 |
||
554 |
private static final CipherSuiteList supportedCipherSuiteList; |
|
555 |
private static final CipherSuiteList serverDefaultCipherSuiteList; |
|
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
556 |
|
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
557 |
static { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
558 |
if (SunJSSE.isFIPS()) { |
34826 | 559 |
supportedProtocolList = new ProtocolList(new String[] { |
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
560 |
ProtocolVersion.TLS10.name, |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
561 |
ProtocolVersion.TLS11.name, |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
562 |
ProtocolVersion.TLS12.name |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
563 |
}); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
564 |
|
34826 | 565 |
serverDefaultProtocolList = new ProtocolList( |
566 |
getAvailableProtocols(new ProtocolVersion[] { |
|
28555 | 567 |
ProtocolVersion.TLS10, |
568 |
ProtocolVersion.TLS11, |
|
569 |
ProtocolVersion.TLS12 |
|
34826 | 570 |
})); |
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
571 |
} else { |
34826 | 572 |
supportedProtocolList = new ProtocolList(new String[] { |
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
573 |
ProtocolVersion.SSL20Hello.name, |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
574 |
ProtocolVersion.SSL30.name, |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
575 |
ProtocolVersion.TLS10.name, |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
576 |
ProtocolVersion.TLS11.name, |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
577 |
ProtocolVersion.TLS12.name |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
578 |
}); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
579 |
|
34826 | 580 |
serverDefaultProtocolList = new ProtocolList( |
581 |
getAvailableProtocols(new ProtocolVersion[] { |
|
28555 | 582 |
ProtocolVersion.SSL20Hello, |
583 |
ProtocolVersion.SSL30, |
|
584 |
ProtocolVersion.TLS10, |
|
585 |
ProtocolVersion.TLS11, |
|
586 |
ProtocolVersion.TLS12 |
|
34826 | 587 |
})); |
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
588 |
} |
28555 | 589 |
|
40275
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
590 |
supportedCipherSuiteList = getApplicableSupportedCipherSuiteList( |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
591 |
supportedProtocolList); |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
592 |
serverDefaultCipherSuiteList = getApplicableEnabledCipherSuiteList( |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
593 |
serverDefaultProtocolList, false); |
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
594 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
595 |
|
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
13815
diff
changeset
|
596 |
@Override |
34826 | 597 |
ProtocolList getSuportedProtocolList() { |
598 |
return supportedProtocolList; |
|
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
599 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
600 |
|
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
13815
diff
changeset
|
601 |
@Override |
34826 | 602 |
CipherSuiteList getSupportedCipherSuiteList() { |
603 |
return supportedCipherSuiteList; |
|
604 |
} |
|
605 |
||
606 |
@Override |
|
607 |
ProtocolList getServerDefaultProtocolList() { |
|
608 |
return serverDefaultProtocolList; |
|
609 |
} |
|
610 |
||
611 |
@Override |
|
612 |
CipherSuiteList getServerDefaultCipherSuiteList() { |
|
613 |
return serverDefaultCipherSuiteList; |
|
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
614 |
} |
28555 | 615 |
|
30904 | 616 |
@Override |
617 |
SSLEngine createSSLEngineImpl() { |
|
618 |
return new SSLEngineImpl(this, false); |
|
619 |
} |
|
28555 | 620 |
|
30904 | 621 |
@Override |
622 |
SSLEngine createSSLEngineImpl(String host, int port) { |
|
623 |
return new SSLEngineImpl(this, host, port, false); |
|
28555 | 624 |
} |
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
625 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
626 |
|
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
627 |
/* |
22068 | 628 |
* The SSLContext implementation for SSLv3 and TLS10 algorithm |
629 |
* |
|
630 |
* @see SSLContext |
|
631 |
*/ |
|
30904 | 632 |
public static final class TLS10Context extends AbstractTLSContext { |
34826 | 633 |
private static final ProtocolList clientDefaultProtocolList; |
634 |
private static final CipherSuiteList clientDefaultCipherSuiteList; |
|
22068 | 635 |
|
636 |
static { |
|
637 |
if (SunJSSE.isFIPS()) { |
|
34826 | 638 |
clientDefaultProtocolList = new ProtocolList( |
639 |
getAvailableProtocols(new ProtocolVersion[] { |
|
28555 | 640 |
ProtocolVersion.TLS10 |
34826 | 641 |
})); |
28555 | 642 |
} else { |
34826 | 643 |
clientDefaultProtocolList = new ProtocolList( |
644 |
getAvailableProtocols(new ProtocolVersion[] { |
|
28555 | 645 |
ProtocolVersion.SSL30, |
646 |
ProtocolVersion.TLS10 |
|
34826 | 647 |
})); |
28555 | 648 |
} |
22068 | 649 |
|
40275
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
650 |
clientDefaultCipherSuiteList = getApplicableEnabledCipherSuiteList( |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
651 |
clientDefaultProtocolList, true); |
22068 | 652 |
} |
653 |
||
654 |
@Override |
|
34826 | 655 |
ProtocolList getClientDefaultProtocolList() { |
656 |
return clientDefaultProtocolList; |
|
657 |
} |
|
658 |
||
659 |
@Override |
|
660 |
CipherSuiteList getClientDefaultCipherSuiteList() { |
|
661 |
return clientDefaultCipherSuiteList; |
|
22068 | 662 |
} |
663 |
} |
|
664 |
||
665 |
/* |
|
666 |
* The SSLContext implementation for TLS11 algorithm |
|
667 |
* |
|
668 |
* @see SSLContext |
|
669 |
*/ |
|
30904 | 670 |
public static final class TLS11Context extends AbstractTLSContext { |
34826 | 671 |
private static final ProtocolList clientDefaultProtocolList; |
672 |
private static final CipherSuiteList clientDefaultCipherSuiteList; |
|
22068 | 673 |
|
674 |
static { |
|
675 |
if (SunJSSE.isFIPS()) { |
|
34826 | 676 |
clientDefaultProtocolList = new ProtocolList( |
677 |
getAvailableProtocols(new ProtocolVersion[] { |
|
28555 | 678 |
ProtocolVersion.TLS10, |
679 |
ProtocolVersion.TLS11 |
|
34826 | 680 |
})); |
28555 | 681 |
} else { |
34826 | 682 |
clientDefaultProtocolList = new ProtocolList( |
683 |
getAvailableProtocols(new ProtocolVersion[] { |
|
28555 | 684 |
ProtocolVersion.SSL30, |
685 |
ProtocolVersion.TLS10, |
|
686 |
ProtocolVersion.TLS11 |
|
34826 | 687 |
})); |
28555 | 688 |
} |
22068 | 689 |
|
40275
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
690 |
clientDefaultCipherSuiteList = getApplicableEnabledCipherSuiteList( |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
691 |
clientDefaultProtocolList, true); |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
692 |
|
22068 | 693 |
} |
694 |
||
695 |
@Override |
|
34826 | 696 |
ProtocolList getClientDefaultProtocolList() { |
697 |
return clientDefaultProtocolList; |
|
698 |
} |
|
699 |
||
700 |
@Override |
|
701 |
CipherSuiteList getClientDefaultCipherSuiteList() { |
|
702 |
return clientDefaultCipherSuiteList; |
|
22068 | 703 |
} |
704 |
} |
|
705 |
||
706 |
/* |
|
707 |
* The SSLContext implementation for TLS12 algorithm |
|
708 |
* |
|
709 |
* @see SSLContext |
|
710 |
*/ |
|
30904 | 711 |
public static final class TLS12Context extends AbstractTLSContext { |
34826 | 712 |
private static final ProtocolList clientDefaultProtocolList; |
713 |
private static final CipherSuiteList clientDefaultCipherSuiteList; |
|
22068 | 714 |
|
715 |
static { |
|
716 |
if (SunJSSE.isFIPS()) { |
|
34826 | 717 |
clientDefaultProtocolList = new ProtocolList( |
718 |
getAvailableProtocols(new ProtocolVersion[] { |
|
28555 | 719 |
ProtocolVersion.TLS10, |
720 |
ProtocolVersion.TLS11, |
|
721 |
ProtocolVersion.TLS12 |
|
34826 | 722 |
})); |
28555 | 723 |
} else { |
34826 | 724 |
clientDefaultProtocolList = new ProtocolList( |
725 |
getAvailableProtocols(new ProtocolVersion[] { |
|
28555 | 726 |
ProtocolVersion.SSL30, |
727 |
ProtocolVersion.TLS10, |
|
728 |
ProtocolVersion.TLS11, |
|
729 |
ProtocolVersion.TLS12 |
|
34826 | 730 |
})); |
28555 | 731 |
} |
22068 | 732 |
|
40275
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
733 |
clientDefaultCipherSuiteList = getApplicableEnabledCipherSuiteList( |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
734 |
clientDefaultProtocolList, true); |
22068 | 735 |
} |
736 |
||
737 |
@Override |
|
34826 | 738 |
ProtocolList getClientDefaultProtocolList() { |
739 |
return clientDefaultProtocolList; |
|
740 |
} |
|
741 |
||
742 |
@Override |
|
743 |
CipherSuiteList getClientDefaultCipherSuiteList() { |
|
744 |
return clientDefaultCipherSuiteList; |
|
22068 | 745 |
} |
746 |
} |
|
747 |
||
748 |
/* |
|
30904 | 749 |
* The interface for the customized SSL/(D)TLS SSLContext. |
750 |
* |
|
751 |
* @see SSLContext |
|
752 |
*/ |
|
753 |
private static class CustomizedSSLProtocols { |
|
32649
2ee9017c7597
8136583: Core libraries should use blessed modifier order
martin
parents:
32032
diff
changeset
|
754 |
private static final String PROPERTY_NAME = "jdk.tls.client.protocols"; |
30904 | 755 |
static IllegalArgumentException reservedException = null; |
756 |
static ArrayList<ProtocolVersion> |
|
757 |
customizedProtocols = new ArrayList<>(); |
|
758 |
||
759 |
// Don't want a java.lang.LinkageError for illegal system property. |
|
760 |
// |
|
761 |
// Please don't throw exception in this static block. Otherwise, |
|
762 |
// java.lang.LinkageError may be thrown during the instantiation of |
|
763 |
// the provider service. Instead, please handle the initialization |
|
764 |
// exception in the caller's constructor. |
|
765 |
static { |
|
37781
71ed5645f17c
8155775: Re-examine naming of privileged methods to access System properties
redestad
parents:
37593
diff
changeset
|
766 |
String property = GetPropertyAction |
71ed5645f17c
8155775: Re-examine naming of privileged methods to access System properties
redestad
parents:
37593
diff
changeset
|
767 |
.privilegedGetProperty(PROPERTY_NAME); |
30904 | 768 |
if (property != null && property.length() != 0) { |
769 |
// remove double quote marks from beginning/end of the property |
|
770 |
if (property.length() > 1 && property.charAt(0) == '"' && |
|
771 |
property.charAt(property.length() - 1) == '"') { |
|
772 |
property = property.substring(1, property.length() - 1); |
|
773 |
} |
|
774 |
} |
|
775 |
||
776 |
if (property != null && property.length() != 0) { |
|
777 |
String[] protocols = property.split(","); |
|
778 |
for (int i = 0; i < protocols.length; i++) { |
|
779 |
protocols[i] = protocols[i].trim(); |
|
780 |
// Is it a supported protocol name? |
|
781 |
try { |
|
782 |
ProtocolVersion pro = |
|
783 |
ProtocolVersion.valueOf(protocols[i]); |
|
784 |
||
785 |
if (SunJSSE.isFIPS() && |
|
786 |
((pro.v == ProtocolVersion.SSL30.v) || |
|
787 |
(pro.v == ProtocolVersion.SSL20Hello.v))) { |
|
788 |
reservedException = new IllegalArgumentException( |
|
789 |
PROPERTY_NAME + ": " + pro + |
|
790 |
" is not FIPS compliant"); |
|
791 |
||
792 |
break; |
|
793 |
} |
|
794 |
||
795 |
// ignore duplicated protocols |
|
796 |
if (!customizedProtocols.contains(pro)) { |
|
797 |
customizedProtocols.add(pro); |
|
798 |
} |
|
799 |
} catch (IllegalArgumentException iae) { |
|
800 |
reservedException = new IllegalArgumentException( |
|
801 |
PROPERTY_NAME + ": " + protocols[i] + |
|
802 |
" is not a standard SSL protocol name", iae); |
|
803 |
} |
|
804 |
} |
|
805 |
} |
|
806 |
} |
|
807 |
} |
|
808 |
||
809 |
/* |
|
22068 | 810 |
* The SSLContext implementation for customized TLS protocols |
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
811 |
* |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
812 |
* @see SSLContext |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
813 |
*/ |
30904 | 814 |
private static class CustomizedTLSContext extends AbstractTLSContext { |
815 |
||
34826 | 816 |
private static final ProtocolList clientDefaultProtocolList; |
817 |
private static final CipherSuiteList clientDefaultCipherSuiteList; |
|
818 |
||
22068 | 819 |
private static IllegalArgumentException reservedException = null; |
820 |
||
821 |
// Don't want a java.lang.LinkageError for illegal system property. |
|
822 |
// |
|
823 |
// Please don't throw exception in this static block. Otherwise, |
|
824 |
// java.lang.LinkageError may be thrown during the instantiation of |
|
825 |
// the provider service. Instead, let's handle the initialization |
|
826 |
// exception in constructor. |
|
827 |
static { |
|
30904 | 828 |
reservedException = CustomizedSSLProtocols.reservedException; |
829 |
if (reservedException == null) { |
|
830 |
ArrayList<ProtocolVersion> |
|
831 |
customizedTLSProtocols = new ArrayList<>(); |
|
832 |
for (ProtocolVersion protocol : |
|
833 |
CustomizedSSLProtocols.customizedProtocols) { |
|
834 |
if (!protocol.isDTLSProtocol()) { |
|
835 |
customizedTLSProtocols.add(protocol); |
|
22068 | 836 |
} |
837 |
} |
|
838 |
||
30904 | 839 |
// candidates for available protocols |
840 |
ProtocolVersion[] candidates; |
|
841 |
if (customizedTLSProtocols.isEmpty()) { |
|
842 |
// Use the default enabled client protocols if no |
|
843 |
// customized TLS protocols. |
|
844 |
if (SunJSSE.isFIPS()) { |
|
845 |
candidates = new ProtocolVersion[] { |
|
846 |
ProtocolVersion.TLS10, |
|
847 |
ProtocolVersion.TLS11, |
|
848 |
ProtocolVersion.TLS12 |
|
849 |
}; |
|
850 |
} else { |
|
851 |
candidates = new ProtocolVersion[] { |
|
852 |
ProtocolVersion.SSL30, |
|
853 |
ProtocolVersion.TLS10, |
|
854 |
ProtocolVersion.TLS11, |
|
855 |
ProtocolVersion.TLS12 |
|
856 |
}; |
|
22068 | 857 |
} |
30904 | 858 |
} else { |
859 |
// Use the customized TLS protocols. |
|
860 |
candidates = |
|
861 |
new ProtocolVersion[customizedTLSProtocols.size()]; |
|
862 |
candidates = customizedTLSProtocols.toArray(candidates); |
|
22068 | 863 |
} |
864 |
||
34826 | 865 |
clientDefaultProtocolList = new ProtocolList( |
28555 | 866 |
getAvailableProtocols(candidates)); |
40275
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
867 |
clientDefaultCipherSuiteList = |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
868 |
getApplicableEnabledCipherSuiteList( |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
869 |
clientDefaultProtocolList, true); |
30904 | 870 |
} else { |
34826 | 871 |
clientDefaultProtocolList = null; // unlikely to be used |
872 |
clientDefaultCipherSuiteList = null; // unlikely to be used |
|
22068 | 873 |
} |
874 |
} |
|
875 |
||
30904 | 876 |
protected CustomizedTLSContext() { |
22068 | 877 |
if (reservedException != null) { |
878 |
throw reservedException; |
|
879 |
} |
|
880 |
} |
|
881 |
||
882 |
@Override |
|
34826 | 883 |
ProtocolList getClientDefaultProtocolList() { |
884 |
return clientDefaultProtocolList; |
|
885 |
} |
|
886 |
||
887 |
@Override |
|
888 |
CipherSuiteList getClientDefaultCipherSuiteList() { |
|
889 |
return clientDefaultCipherSuiteList; |
|
22068 | 890 |
} |
891 |
} |
|
892 |
||
893 |
/* |
|
894 |
* The SSLContext implementation for default "TLS" algorithm |
|
895 |
* |
|
896 |
* @see SSLContext |
|
897 |
*/ |
|
30904 | 898 |
public static final class TLSContext extends CustomizedTLSContext { |
22068 | 899 |
// use the default constructor and methods |
900 |
} |
|
901 |
||
34826 | 902 |
// lazy initialization holder class idiom for static default parameters |
903 |
// |
|
904 |
// See Effective Java Second Edition: Item 71. |
|
905 |
private static final class DefaultManagersHolder { |
|
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
906 |
private static final String NONE = "NONE"; |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
907 |
private static final String P11KEYSTORE = "PKCS11"; |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
908 |
|
34826 | 909 |
private static final TrustManager[] trustManagers; |
910 |
private static final KeyManager[] keyManagers; |
|
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
911 |
|
34826 | 912 |
static Exception reservedException = null; |
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
913 |
|
34826 | 914 |
static { |
915 |
TrustManager[] tmMediator; |
|
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
916 |
try { |
34826 | 917 |
tmMediator = getTrustManagers(); |
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
918 |
} catch (Exception e) { |
34826 | 919 |
reservedException = e; |
920 |
tmMediator = new TrustManager[0]; |
|
921 |
} |
|
922 |
trustManagers = tmMediator; |
|
923 |
||
924 |
if (reservedException == null) { |
|
925 |
KeyManager[] kmMediator; |
|
926 |
try { |
|
927 |
kmMediator = getKeyManagers(); |
|
928 |
} catch (Exception e) { |
|
929 |
reservedException = e; |
|
930 |
kmMediator = new KeyManager[0]; |
|
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
931 |
} |
34826 | 932 |
keyManagers = kmMediator; |
933 |
} else { |
|
934 |
keyManagers = new KeyManager[0]; |
|
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
935 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
936 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
937 |
|
34826 | 938 |
private static TrustManager[] getTrustManagers() throws Exception { |
43009
5af9f7aa93e5
8129988: JSSE should create a single instance of the cacerts KeyStore
xuelei
parents:
42221
diff
changeset
|
939 |
TrustManagerFactory tmf = TrustManagerFactory.getInstance( |
5af9f7aa93e5
8129988: JSSE should create a single instance of the cacerts KeyStore
xuelei
parents:
42221
diff
changeset
|
940 |
TrustManagerFactory.getDefaultAlgorithm()); |
5af9f7aa93e5
8129988: JSSE should create a single instance of the cacerts KeyStore
xuelei
parents:
42221
diff
changeset
|
941 |
if ("SunJSSE".equals(tmf.getProvider().getName())) { |
5af9f7aa93e5
8129988: JSSE should create a single instance of the cacerts KeyStore
xuelei
parents:
42221
diff
changeset
|
942 |
// The implementation will load the default KeyStore |
5af9f7aa93e5
8129988: JSSE should create a single instance of the cacerts KeyStore
xuelei
parents:
42221
diff
changeset
|
943 |
// automatically. Cached trust materials may be used |
5af9f7aa93e5
8129988: JSSE should create a single instance of the cacerts KeyStore
xuelei
parents:
42221
diff
changeset
|
944 |
// for performance improvement. |
5af9f7aa93e5
8129988: JSSE should create a single instance of the cacerts KeyStore
xuelei
parents:
42221
diff
changeset
|
945 |
tmf.init((KeyStore)null); |
5af9f7aa93e5
8129988: JSSE should create a single instance of the cacerts KeyStore
xuelei
parents:
42221
diff
changeset
|
946 |
} else { |
5af9f7aa93e5
8129988: JSSE should create a single instance of the cacerts KeyStore
xuelei
parents:
42221
diff
changeset
|
947 |
// Use the explicitly specified KeyStore for third party's |
5af9f7aa93e5
8129988: JSSE should create a single instance of the cacerts KeyStore
xuelei
parents:
42221
diff
changeset
|
948 |
// TrustManagerFactory implementation. |
5af9f7aa93e5
8129988: JSSE should create a single instance of the cacerts KeyStore
xuelei
parents:
42221
diff
changeset
|
949 |
KeyStore ks = TrustStoreManager.getTrustedKeyStore(); |
5af9f7aa93e5
8129988: JSSE should create a single instance of the cacerts KeyStore
xuelei
parents:
42221
diff
changeset
|
950 |
tmf.init(ks); |
5af9f7aa93e5
8129988: JSSE should create a single instance of the cacerts KeyStore
xuelei
parents:
42221
diff
changeset
|
951 |
} |
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
952 |
|
34826 | 953 |
return tmf.getTrustManagers(); |
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
954 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
955 |
|
34826 | 956 |
private static KeyManager[] getKeyManagers() throws Exception { |
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
957 |
|
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
958 |
final Map<String,String> props = new HashMap<>(); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
959 |
AccessController.doPrivileged( |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
960 |
new PrivilegedExceptionAction<Object>() { |
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
13815
diff
changeset
|
961 |
@Override |
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
962 |
public Object run() throws Exception { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
963 |
props.put("keyStore", System.getProperty( |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
964 |
"javax.net.ssl.keyStore", "")); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
965 |
props.put("keyStoreType", System.getProperty( |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
966 |
"javax.net.ssl.keyStoreType", |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
967 |
KeyStore.getDefaultType())); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
968 |
props.put("keyStoreProvider", System.getProperty( |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
969 |
"javax.net.ssl.keyStoreProvider", "")); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
970 |
props.put("keyStorePasswd", System.getProperty( |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
971 |
"javax.net.ssl.keyStorePassword", "")); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
972 |
return null; |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
973 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
974 |
}); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
975 |
|
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
976 |
final String defaultKeyStore = props.get("keyStore"); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
977 |
String defaultKeyStoreType = props.get("keyStoreType"); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
978 |
String defaultKeyStoreProvider = props.get("keyStoreProvider"); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
979 |
if (debug != null && Debug.isOn("defaultctx")) { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
980 |
System.out.println("keyStore is : " + defaultKeyStore); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
981 |
System.out.println("keyStore type is : " + |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
982 |
defaultKeyStoreType); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
983 |
System.out.println("keyStore provider is : " + |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
984 |
defaultKeyStoreProvider); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
985 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
986 |
|
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
987 |
if (P11KEYSTORE.equals(defaultKeyStoreType) && |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
988 |
!NONE.equals(defaultKeyStore)) { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
989 |
throw new IllegalArgumentException("if keyStoreType is " |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
990 |
+ P11KEYSTORE + ", then keyStore must be " + NONE); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
991 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
992 |
|
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
993 |
FileInputStream fs = null; |
10125 | 994 |
KeyStore ks = null; |
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
995 |
char[] passwd = null; |
10125 | 996 |
try { |
997 |
if (defaultKeyStore.length() != 0 && |
|
998 |
!NONE.equals(defaultKeyStore)) { |
|
999 |
fs = AccessController.doPrivileged( |
|
1000 |
new PrivilegedExceptionAction<FileInputStream>() { |
|
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
13815
diff
changeset
|
1001 |
@Override |
10125 | 1002 |
public FileInputStream run() throws Exception { |
1003 |
return new FileInputStream(defaultKeyStore); |
|
1004 |
} |
|
1005 |
}); |
|
1006 |
} |
|
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
1007 |
|
10125 | 1008 |
String defaultKeyStorePassword = props.get("keyStorePasswd"); |
1009 |
if (defaultKeyStorePassword.length() != 0) { |
|
1010 |
passwd = defaultKeyStorePassword.toCharArray(); |
|
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
1011 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
1012 |
|
10125 | 1013 |
/** |
1014 |
* Try to initialize key store. |
|
1015 |
*/ |
|
1016 |
if ((defaultKeyStoreType.length()) != 0) { |
|
1017 |
if (debug != null && Debug.isOn("defaultctx")) { |
|
1018 |
System.out.println("init keystore"); |
|
1019 |
} |
|
1020 |
if (defaultKeyStoreProvider.length() == 0) { |
|
1021 |
ks = KeyStore.getInstance(defaultKeyStoreType); |
|
1022 |
} else { |
|
1023 |
ks = KeyStore.getInstance(defaultKeyStoreType, |
|
1024 |
defaultKeyStoreProvider); |
|
1025 |
} |
|
1026 |
||
1027 |
// if defaultKeyStore is NONE, fs will be null |
|
1028 |
ks.load(fs, passwd); |
|
1029 |
} |
|
1030 |
} finally { |
|
1031 |
if (fs != null) { |
|
1032 |
fs.close(); |
|
1033 |
fs = null; |
|
1034 |
} |
|
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
1035 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
1036 |
|
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
1037 |
/* |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
1038 |
* Try to initialize key manager. |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
1039 |
*/ |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
1040 |
if (debug != null && Debug.isOn("defaultctx")) { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
1041 |
System.out.println("init keymanager of type " + |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
1042 |
KeyManagerFactory.getDefaultAlgorithm()); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
1043 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
1044 |
KeyManagerFactory kmf = KeyManagerFactory.getInstance( |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
1045 |
KeyManagerFactory.getDefaultAlgorithm()); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
1046 |
|
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
1047 |
if (P11KEYSTORE.equals(defaultKeyStoreType)) { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
1048 |
kmf.init(ks, null); // do not pass key passwd if using token |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
1049 |
} else { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
1050 |
kmf.init(ks, passwd); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
1051 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
1052 |
|
34826 | 1053 |
return kmf.getKeyManagers(); |
1054 |
} |
|
1055 |
} |
|
1056 |
||
1057 |
// lazy initialization holder class idiom for static default parameters |
|
1058 |
// |
|
1059 |
// See Effective Java Second Edition: Item 71. |
|
1060 |
private static final class DefaultSSLContextHolder { |
|
1061 |
||
1062 |
private static final SSLContextImpl sslContext; |
|
1063 |
static Exception reservedException = null; |
|
1064 |
||
1065 |
static { |
|
1066 |
SSLContextImpl mediator = null; |
|
1067 |
if (DefaultManagersHolder.reservedException != null) { |
|
1068 |
reservedException = DefaultManagersHolder.reservedException; |
|
1069 |
} else { |
|
1070 |
try { |
|
1071 |
mediator = new DefaultSSLContext(); |
|
1072 |
} catch (Exception e) { |
|
1073 |
reservedException = e; |
|
1074 |
} |
|
1075 |
} |
|
1076 |
||
1077 |
sslContext = mediator; |
|
1078 |
} |
|
1079 |
} |
|
1080 |
||
1081 |
/* |
|
1082 |
* The SSLContext implementation for default "Default" algorithm |
|
1083 |
* |
|
1084 |
* @see SSLContext |
|
1085 |
*/ |
|
1086 |
public static final class DefaultSSLContext extends CustomizedTLSContext { |
|
1087 |
||
1088 |
// public constructor for SSLContext.getInstance("Default") |
|
1089 |
public DefaultSSLContext() throws Exception { |
|
1090 |
if (DefaultManagersHolder.reservedException != null) { |
|
1091 |
throw DefaultManagersHolder.reservedException; |
|
1092 |
} |
|
1093 |
||
1094 |
try { |
|
1095 |
super.engineInit(DefaultManagersHolder.keyManagers, |
|
1096 |
DefaultManagersHolder.trustManagers, null); |
|
1097 |
} catch (Exception e) { |
|
1098 |
if (debug != null && Debug.isOn("defaultctx")) { |
|
1099 |
System.out.println("default context init failed: " + e); |
|
1100 |
} |
|
1101 |
throw e; |
|
1102 |
} |
|
1103 |
} |
|
1104 |
||
1105 |
@Override |
|
1106 |
protected void engineInit(KeyManager[] km, TrustManager[] tm, |
|
1107 |
SecureRandom sr) throws KeyManagementException { |
|
1108 |
throw new KeyManagementException |
|
1109 |
("Default SSLContext is initialized automatically"); |
|
1110 |
} |
|
1111 |
||
1112 |
static SSLContextImpl getDefaultImpl() throws Exception { |
|
1113 |
if (DefaultSSLContextHolder.reservedException != null) { |
|
1114 |
throw DefaultSSLContextHolder.reservedException; |
|
1115 |
} |
|
1116 |
||
1117 |
return DefaultSSLContextHolder.sslContext; |
|
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
1118 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
1119 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
1120 |
|
30904 | 1121 |
/* |
1122 |
* The base abstract SSLContext implementation for the Datagram Transport |
|
1123 |
* Layer Security (DTLS) protocols. |
|
1124 |
* |
|
1125 |
* This abstract class encapsulates supported and the default server DTLS |
|
1126 |
* parameters. |
|
1127 |
* |
|
1128 |
* @see SSLContext |
|
1129 |
*/ |
|
1130 |
private abstract static class AbstractDTLSContext extends SSLContextImpl { |
|
34826 | 1131 |
private static final ProtocolList supportedProtocolList; |
1132 |
private static final ProtocolList serverDefaultProtocolList; |
|
1133 |
||
1134 |
private static final CipherSuiteList supportedCipherSuiteList; |
|
1135 |
private static final CipherSuiteList serverDefaultCipherSuiteList; |
|
30904 | 1136 |
|
1137 |
static { |
|
1138 |
// Both DTLSv1.0 and DTLSv1.2 can be used in FIPS mode. |
|
34826 | 1139 |
supportedProtocolList = new ProtocolList(new String[] { |
30904 | 1140 |
ProtocolVersion.DTLS10.name, |
1141 |
ProtocolVersion.DTLS12.name |
|
1142 |
}); |
|
1143 |
||
34826 | 1144 |
// available protocols for server mode |
1145 |
serverDefaultProtocolList = new ProtocolList( |
|
1146 |
getAvailableProtocols(new ProtocolVersion[] { |
|
30904 | 1147 |
ProtocolVersion.DTLS10, |
1148 |
ProtocolVersion.DTLS12 |
|
34826 | 1149 |
})); |
30904 | 1150 |
|
40275
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
1151 |
supportedCipherSuiteList = getApplicableSupportedCipherSuiteList( |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
1152 |
supportedProtocolList); |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
1153 |
serverDefaultCipherSuiteList = getApplicableEnabledCipherSuiteList( |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
1154 |
serverDefaultProtocolList, false); |
30904 | 1155 |
} |
1156 |
||
1157 |
@Override |
|
34826 | 1158 |
ProtocolList getSuportedProtocolList() { |
1159 |
return supportedProtocolList; |
|
30904 | 1160 |
} |
1161 |
||
1162 |
@Override |
|
34826 | 1163 |
CipherSuiteList getSupportedCipherSuiteList() { |
1164 |
return supportedCipherSuiteList; |
|
1165 |
} |
|
1166 |
||
1167 |
@Override |
|
1168 |
ProtocolList getServerDefaultProtocolList() { |
|
1169 |
return serverDefaultProtocolList; |
|
1170 |
} |
|
1171 |
||
1172 |
@Override |
|
1173 |
CipherSuiteList getServerDefaultCipherSuiteList() { |
|
1174 |
return serverDefaultCipherSuiteList; |
|
30904 | 1175 |
} |
1176 |
||
1177 |
@Override |
|
1178 |
SSLEngine createSSLEngineImpl() { |
|
1179 |
return new SSLEngineImpl(this, true); |
|
1180 |
} |
|
1181 |
||
1182 |
@Override |
|
1183 |
SSLEngine createSSLEngineImpl(String host, int port) { |
|
1184 |
return new SSLEngineImpl(this, host, port, true); |
|
1185 |
} |
|
1186 |
||
1187 |
@Override |
|
1188 |
HelloCookieManager getHelloCookieManager(SecureRandom secureRandom) { |
|
1189 |
return new HelloCookieManager(secureRandom); |
|
1190 |
} |
|
1191 |
} |
|
1192 |
||
1193 |
/* |
|
1194 |
* The SSLContext implementation for DTLSv1.0 algorithm. |
|
1195 |
* |
|
1196 |
* @see SSLContext |
|
1197 |
*/ |
|
1198 |
public static final class DTLS10Context extends AbstractDTLSContext { |
|
34826 | 1199 |
private static final ProtocolList clientDefaultProtocolList; |
1200 |
private static final CipherSuiteList clientDefaultCipherSuiteList; |
|
30904 | 1201 |
|
1202 |
static { |
|
34826 | 1203 |
// available protocols for client mode |
1204 |
clientDefaultProtocolList = new ProtocolList( |
|
1205 |
getAvailableProtocols(new ProtocolVersion[] { |
|
30904 | 1206 |
ProtocolVersion.DTLS10 |
34826 | 1207 |
})); |
30904 | 1208 |
|
40275
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
1209 |
clientDefaultCipherSuiteList = getApplicableEnabledCipherSuiteList( |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
1210 |
clientDefaultProtocolList, true); |
30904 | 1211 |
} |
1212 |
||
1213 |
@Override |
|
34826 | 1214 |
ProtocolList getClientDefaultProtocolList() { |
1215 |
return clientDefaultProtocolList; |
|
1216 |
} |
|
1217 |
||
1218 |
@Override |
|
1219 |
CipherSuiteList getClientDefaultCipherSuiteList() { |
|
1220 |
return clientDefaultCipherSuiteList; |
|
30904 | 1221 |
} |
1222 |
} |
|
1223 |
||
1224 |
/* |
|
1225 |
* The SSLContext implementation for DTLSv1.2 algorithm. |
|
1226 |
* |
|
1227 |
* @see SSLContext |
|
1228 |
*/ |
|
1229 |
public static final class DTLS12Context extends AbstractDTLSContext { |
|
34826 | 1230 |
private static final ProtocolList clientDefaultProtocolList; |
1231 |
private static final CipherSuiteList clientDefaultCipherSuiteList; |
|
30904 | 1232 |
|
1233 |
static { |
|
34826 | 1234 |
// available protocols for client mode |
1235 |
clientDefaultProtocolList = new ProtocolList( |
|
1236 |
getAvailableProtocols(new ProtocolVersion[] { |
|
30904 | 1237 |
ProtocolVersion.DTLS10, |
1238 |
ProtocolVersion.DTLS12 |
|
34826 | 1239 |
})); |
30904 | 1240 |
|
40275
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
1241 |
clientDefaultCipherSuiteList = getApplicableEnabledCipherSuiteList( |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
1242 |
clientDefaultProtocolList, true); |
30904 | 1243 |
} |
1244 |
||
1245 |
@Override |
|
34826 | 1246 |
ProtocolList getClientDefaultProtocolList() { |
1247 |
return clientDefaultProtocolList; |
|
1248 |
} |
|
1249 |
||
1250 |
@Override |
|
1251 |
CipherSuiteList getClientDefaultCipherSuiteList() { |
|
1252 |
return clientDefaultCipherSuiteList; |
|
30904 | 1253 |
} |
1254 |
} |
|
1255 |
||
1256 |
/* |
|
1257 |
* The SSLContext implementation for customized TLS protocols |
|
1258 |
* |
|
1259 |
* @see SSLContext |
|
1260 |
*/ |
|
1261 |
private static class CustomizedDTLSContext extends AbstractDTLSContext { |
|
34826 | 1262 |
private static final ProtocolList clientDefaultProtocolList; |
1263 |
private static final CipherSuiteList clientDefaultCipherSuiteList; |
|
1264 |
||
30904 | 1265 |
private static IllegalArgumentException reservedException = null; |
1266 |
||
1267 |
// Don't want a java.lang.LinkageError for illegal system property. |
|
1268 |
// |
|
1269 |
// Please don't throw exception in this static block. Otherwise, |
|
1270 |
// java.lang.LinkageError may be thrown during the instantiation of |
|
1271 |
// the provider service. Instead, let's handle the initialization |
|
1272 |
// exception in constructor. |
|
1273 |
static { |
|
1274 |
reservedException = CustomizedSSLProtocols.reservedException; |
|
1275 |
if (reservedException == null) { |
|
1276 |
ArrayList<ProtocolVersion> |
|
1277 |
customizedDTLSProtocols = new ArrayList<>(); |
|
1278 |
for (ProtocolVersion protocol : |
|
1279 |
CustomizedSSLProtocols.customizedProtocols) { |
|
1280 |
if (protocol.isDTLSProtocol()) { |
|
1281 |
customizedDTLSProtocols.add(protocol); |
|
1282 |
} |
|
1283 |
} |
|
1284 |
||
1285 |
// candidates for available protocols |
|
1286 |
ProtocolVersion[] candidates; |
|
1287 |
if (customizedDTLSProtocols.isEmpty()) { |
|
1288 |
// Use the default enabled client protocols if no |
|
1289 |
// customized TLS protocols. |
|
1290 |
// |
|
1291 |
// Both DTLSv1.0 and DTLSv1.2 can be used in FIPS mode. |
|
1292 |
candidates = new ProtocolVersion[] { |
|
1293 |
ProtocolVersion.DTLS10, |
|
1294 |
ProtocolVersion.DTLS12 |
|
1295 |
}; |
|
1296 |
||
1297 |
} else { |
|
1298 |
// Use the customized TLS protocols. |
|
1299 |
candidates = |
|
1300 |
new ProtocolVersion[customizedDTLSProtocols.size()]; |
|
1301 |
candidates = customizedDTLSProtocols.toArray(candidates); |
|
1302 |
} |
|
1303 |
||
34826 | 1304 |
clientDefaultProtocolList = new ProtocolList( |
30904 | 1305 |
getAvailableProtocols(candidates)); |
40275
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
1306 |
clientDefaultCipherSuiteList = |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
1307 |
getApplicableEnabledCipherSuiteList( |
6a37d5a9619d
8162362: Introduce system property to control enabled ciphersuites
xuelei
parents:
37781
diff
changeset
|
1308 |
clientDefaultProtocolList, true); |
30904 | 1309 |
} else { |
34826 | 1310 |
clientDefaultProtocolList = null; // unlikely to be used |
1311 |
clientDefaultCipherSuiteList = null; // unlikely to be used |
|
30904 | 1312 |
} |
1313 |
} |
|
1314 |
||
1315 |
protected CustomizedDTLSContext() { |
|
1316 |
if (reservedException != null) { |
|
1317 |
throw reservedException; |
|
1318 |
} |
|
1319 |
} |
|
1320 |
||
1321 |
@Override |
|
34826 | 1322 |
ProtocolList getClientDefaultProtocolList() { |
1323 |
return clientDefaultProtocolList; |
|
1324 |
} |
|
1325 |
||
1326 |
@Override |
|
1327 |
CipherSuiteList getClientDefaultCipherSuiteList() { |
|
1328 |
return clientDefaultCipherSuiteList; |
|
30904 | 1329 |
} |
1330 |
} |
|
1331 |
||
1332 |
/* |
|
1333 |
* The SSLContext implementation for default "DTLS" algorithm |
|
1334 |
* |
|
1335 |
* @see SSLContext |
|
1336 |
*/ |
|
1337 |
public static final class DTLSContext extends CustomizedDTLSContext { |
|
1338 |
// use the default constructor and methods |
|
1339 |
} |
|
1340 |
||
2 | 1341 |
} |
1342 |
||
7043 | 1343 |
|
1344 |
final class AbstractTrustManagerWrapper extends X509ExtendedTrustManager |
|
1345 |
implements X509TrustManager { |
|
1346 |
||
11037
03c29eb4afa0
7113275: compatibility issue with MD2 trust anchor and old X509TrustManager
xuelei
parents:
10125
diff
changeset
|
1347 |
// the delegated trust manager |
7043 | 1348 |
private final X509TrustManager tm; |
1349 |
||
1350 |
AbstractTrustManagerWrapper(X509TrustManager tm) { |
|
1351 |
this.tm = tm; |
|
1352 |
} |
|
1353 |
||
1354 |
@Override |
|
1355 |
public void checkClientTrusted(X509Certificate[] chain, String authType) |
|
1356 |
throws CertificateException { |
|
1357 |
tm.checkClientTrusted(chain, authType); |
|
1358 |
} |
|
1359 |
||
1360 |
@Override |
|
1361 |
public void checkServerTrusted(X509Certificate[] chain, String authType) |
|
1362 |
throws CertificateException { |
|
1363 |
tm.checkServerTrusted(chain, authType); |
|
1364 |
} |
|
1365 |
||
1366 |
@Override |
|
1367 |
public X509Certificate[] getAcceptedIssuers() { |
|
1368 |
return tm.getAcceptedIssuers(); |
|
1369 |
} |
|
1370 |
||
1371 |
@Override |
|
1372 |
public void checkClientTrusted(X509Certificate[] chain, String authType, |
|
1373 |
Socket socket) throws CertificateException { |
|
1374 |
tm.checkClientTrusted(chain, authType); |
|
1375 |
checkAdditionalTrust(chain, authType, socket, true); |
|
1376 |
} |
|
1377 |
||
1378 |
@Override |
|
1379 |
public void checkServerTrusted(X509Certificate[] chain, String authType, |
|
1380 |
Socket socket) throws CertificateException { |
|
1381 |
tm.checkServerTrusted(chain, authType); |
|
1382 |
checkAdditionalTrust(chain, authType, socket, false); |
|
1383 |
} |
|
1384 |
||
1385 |
@Override |
|
1386 |
public void checkClientTrusted(X509Certificate[] chain, String authType, |
|
1387 |
SSLEngine engine) throws CertificateException { |
|
1388 |
tm.checkClientTrusted(chain, authType); |
|
1389 |
checkAdditionalTrust(chain, authType, engine, true); |
|
1390 |
} |
|
1391 |
||
1392 |
@Override |
|
1393 |
public void checkServerTrusted(X509Certificate[] chain, String authType, |
|
1394 |
SSLEngine engine) throws CertificateException { |
|
1395 |
tm.checkServerTrusted(chain, authType); |
|
1396 |
checkAdditionalTrust(chain, authType, engine, false); |
|
1397 |
} |
|
1398 |
||
1399 |
private void checkAdditionalTrust(X509Certificate[] chain, String authType, |
|
1400 |
Socket socket, boolean isClient) throws CertificateException { |
|
1401 |
if (socket != null && socket.isConnected() && |
|
1402 |
socket instanceof SSLSocket) { |
|
1403 |
||
1404 |
SSLSocket sslSocket = (SSLSocket)socket; |
|
1405 |
SSLSession session = sslSocket.getHandshakeSession(); |
|
1406 |
if (session == null) { |
|
1407 |
throw new CertificateException("No handshake session"); |
|
1408 |
} |
|
1409 |
||
1410 |
// check endpoint identity |
|
1411 |
String identityAlg = sslSocket.getSSLParameters(). |
|
1412 |
getEndpointIdentificationAlgorithm(); |
|
1413 |
if (identityAlg != null && identityAlg.length() != 0) { |
|
1414 |
String hostname = session.getPeerHost(); |
|
1415 |
X509TrustManagerImpl.checkIdentity( |
|
1416 |
hostname, chain[0], identityAlg); |
|
1417 |
} |
|
1418 |
||
1419 |
// try the best to check the algorithm constraints |
|
1420 |
ProtocolVersion protocolVersion = |
|
1421 |
ProtocolVersion.valueOf(session.getProtocol()); |
|
1422 |
AlgorithmConstraints constraints = null; |
|
30904 | 1423 |
if (protocolVersion.useTLS12PlusSpec()) { |
7043 | 1424 |
if (session instanceof ExtendedSSLSession) { |
1425 |
ExtendedSSLSession extSession = |
|
1426 |
(ExtendedSSLSession)session; |
|
1427 |
String[] peerSupportedSignAlgs = |
|
1428 |
extSession.getLocalSupportedSignatureAlgorithms(); |
|
1429 |
||
1430 |
constraints = new SSLAlgorithmConstraints( |
|
1431 |
sslSocket, peerSupportedSignAlgs, true); |
|
1432 |
} else { |
|
1433 |
constraints = |
|
1434 |
new SSLAlgorithmConstraints(sslSocket, true); |
|
1435 |
} |
|
1436 |
} else { |
|
1437 |
constraints = new SSLAlgorithmConstraints(sslSocket, true); |
|
1438 |
} |
|
1439 |
||
43701
fe8c324ba97c
8160655: Fix denyAfter and usage types for security properties
ascarpino
parents:
43009
diff
changeset
|
1440 |
checkAlgorithmConstraints(chain, constraints, isClient); |
7043 | 1441 |
} |
1442 |
} |
|
1443 |
||
1444 |
private void checkAdditionalTrust(X509Certificate[] chain, String authType, |
|
1445 |
SSLEngine engine, boolean isClient) throws CertificateException { |
|
1446 |
if (engine != null) { |
|
1447 |
SSLSession session = engine.getHandshakeSession(); |
|
1448 |
if (session == null) { |
|
1449 |
throw new CertificateException("No handshake session"); |
|
1450 |
} |
|
1451 |
||
1452 |
// check endpoint identity |
|
1453 |
String identityAlg = engine.getSSLParameters(). |
|
1454 |
getEndpointIdentificationAlgorithm(); |
|
1455 |
if (identityAlg != null && identityAlg.length() != 0) { |
|
1456 |
String hostname = session.getPeerHost(); |
|
1457 |
X509TrustManagerImpl.checkIdentity( |
|
1458 |
hostname, chain[0], identityAlg); |
|
1459 |
} |
|
1460 |
||
1461 |
// try the best to check the algorithm constraints |
|
1462 |
ProtocolVersion protocolVersion = |
|
1463 |
ProtocolVersion.valueOf(session.getProtocol()); |
|
1464 |
AlgorithmConstraints constraints = null; |
|
30904 | 1465 |
if (protocolVersion.useTLS12PlusSpec()) { |
7043 | 1466 |
if (session instanceof ExtendedSSLSession) { |
1467 |
ExtendedSSLSession extSession = |
|
1468 |
(ExtendedSSLSession)session; |
|
1469 |
String[] peerSupportedSignAlgs = |
|
1470 |
extSession.getLocalSupportedSignatureAlgorithms(); |
|
1471 |
||
1472 |
constraints = new SSLAlgorithmConstraints( |
|
1473 |
engine, peerSupportedSignAlgs, true); |
|
1474 |
} else { |
|
1475 |
constraints = |
|
1476 |
new SSLAlgorithmConstraints(engine, true); |
|
1477 |
} |
|
1478 |
} else { |
|
1479 |
constraints = new SSLAlgorithmConstraints(engine, true); |
|
1480 |
} |
|
1481 |
||
43701
fe8c324ba97c
8160655: Fix denyAfter and usage types for security properties
ascarpino
parents:
43009
diff
changeset
|
1482 |
checkAlgorithmConstraints(chain, constraints, isClient); |
11037
03c29eb4afa0
7113275: compatibility issue with MD2 trust anchor and old X509TrustManager
xuelei
parents:
10125
diff
changeset
|
1483 |
} |
03c29eb4afa0
7113275: compatibility issue with MD2 trust anchor and old X509TrustManager
xuelei
parents:
10125
diff
changeset
|
1484 |
} |
03c29eb4afa0
7113275: compatibility issue with MD2 trust anchor and old X509TrustManager
xuelei
parents:
10125
diff
changeset
|
1485 |
|
03c29eb4afa0
7113275: compatibility issue with MD2 trust anchor and old X509TrustManager
xuelei
parents:
10125
diff
changeset
|
1486 |
private void checkAlgorithmConstraints(X509Certificate[] chain, |
43701
fe8c324ba97c
8160655: Fix denyAfter and usage types for security properties
ascarpino
parents:
43009
diff
changeset
|
1487 |
AlgorithmConstraints constraints, boolean isClient) throws CertificateException { |
11037
03c29eb4afa0
7113275: compatibility issue with MD2 trust anchor and old X509TrustManager
xuelei
parents:
10125
diff
changeset
|
1488 |
|
03c29eb4afa0
7113275: compatibility issue with MD2 trust anchor and old X509TrustManager
xuelei
parents:
10125
diff
changeset
|
1489 |
try { |
03c29eb4afa0
7113275: compatibility issue with MD2 trust anchor and old X509TrustManager
xuelei
parents:
10125
diff
changeset
|
1490 |
// Does the certificate chain end with a trusted certificate? |
03c29eb4afa0
7113275: compatibility issue with MD2 trust anchor and old X509TrustManager
xuelei
parents:
10125
diff
changeset
|
1491 |
int checkedLength = chain.length - 1; |
12302
0c8557ba0b8f
7142172: Custom TrustManagers that return null for getAcceptedIssuers will NPE
wetmore
parents:
11037
diff
changeset
|
1492 |
|
0c8557ba0b8f
7142172: Custom TrustManagers that return null for getAcceptedIssuers will NPE
wetmore
parents:
11037
diff
changeset
|
1493 |
Collection<X509Certificate> trustedCerts = new HashSet<>(); |
0c8557ba0b8f
7142172: Custom TrustManagers that return null for getAcceptedIssuers will NPE
wetmore
parents:
11037
diff
changeset
|
1494 |
X509Certificate[] certs = tm.getAcceptedIssuers(); |
0c8557ba0b8f
7142172: Custom TrustManagers that return null for getAcceptedIssuers will NPE
wetmore
parents:
11037
diff
changeset
|
1495 |
if ((certs != null) && (certs.length > 0)){ |
0c8557ba0b8f
7142172: Custom TrustManagers that return null for getAcceptedIssuers will NPE
wetmore
parents:
11037
diff
changeset
|
1496 |
Collections.addAll(trustedCerts, certs); |
0c8557ba0b8f
7142172: Custom TrustManagers that return null for getAcceptedIssuers will NPE
wetmore
parents:
11037
diff
changeset
|
1497 |
} |
0c8557ba0b8f
7142172: Custom TrustManagers that return null for getAcceptedIssuers will NPE
wetmore
parents:
11037
diff
changeset
|
1498 |
|
11037
03c29eb4afa0
7113275: compatibility issue with MD2 trust anchor and old X509TrustManager
xuelei
parents:
10125
diff
changeset
|
1499 |
if (trustedCerts.contains(chain[checkedLength])) { |
03c29eb4afa0
7113275: compatibility issue with MD2 trust anchor and old X509TrustManager
xuelei
parents:
10125
diff
changeset
|
1500 |
checkedLength--; |
03c29eb4afa0
7113275: compatibility issue with MD2 trust anchor and old X509TrustManager
xuelei
parents:
10125
diff
changeset
|
1501 |
} |
03c29eb4afa0
7113275: compatibility issue with MD2 trust anchor and old X509TrustManager
xuelei
parents:
10125
diff
changeset
|
1502 |
|
03c29eb4afa0
7113275: compatibility issue with MD2 trust anchor and old X509TrustManager
xuelei
parents:
10125
diff
changeset
|
1503 |
// A forward checker, need to check from trust to target |
03c29eb4afa0
7113275: compatibility issue with MD2 trust anchor and old X509TrustManager
xuelei
parents:
10125
diff
changeset
|
1504 |
if (checkedLength >= 0) { |
43701
fe8c324ba97c
8160655: Fix denyAfter and usage types for security properties
ascarpino
parents:
43009
diff
changeset
|
1505 |
AlgorithmChecker checker = |
fe8c324ba97c
8160655: Fix denyAfter and usage types for security properties
ascarpino
parents:
43009
diff
changeset
|
1506 |
new AlgorithmChecker(constraints, null, |
fe8c324ba97c
8160655: Fix denyAfter and usage types for security properties
ascarpino
parents:
43009
diff
changeset
|
1507 |
(isClient ? Validator.VAR_TLS_CLIENT : Validator.VAR_TLS_SERVER)); |
7043 | 1508 |
checker.init(false); |
11037
03c29eb4afa0
7113275: compatibility issue with MD2 trust anchor and old X509TrustManager
xuelei
parents:
10125
diff
changeset
|
1509 |
for (int i = checkedLength; i >= 0; i--) { |
7043 | 1510 |
Certificate cert = chain[i]; |
1511 |
// We don't care about the unresolved critical extensions. |
|
1512 |
checker.check(cert, Collections.<String>emptySet()); |
|
1513 |
} |
|
1514 |
} |
|
11037
03c29eb4afa0
7113275: compatibility issue with MD2 trust anchor and old X509TrustManager
xuelei
parents:
10125
diff
changeset
|
1515 |
} catch (CertPathValidatorException cpve) { |
03c29eb4afa0
7113275: compatibility issue with MD2 trust anchor and old X509TrustManager
xuelei
parents:
10125
diff
changeset
|
1516 |
throw new CertificateException( |
40700
b75806acf716
8164846: CertificateException missing cause of underlying exception
coffeys
parents:
40275
diff
changeset
|
1517 |
"Certificates do not conform to algorithm constraints", cpve); |
7043 | 1518 |
} |
1519 |
} |
|
1520 |
} |
|
1521 |
||
2 | 1522 |
// Dummy X509TrustManager implementation, rejects all peer certificates. |
1523 |
// Used if the application did not specify a proper X509TrustManager. |
|
7043 | 1524 |
final class DummyX509TrustManager extends X509ExtendedTrustManager |
1525 |
implements X509TrustManager { |
|
2 | 1526 |
|
1527 |
static final X509TrustManager INSTANCE = new DummyX509TrustManager(); |
|
1528 |
||
1529 |
private DummyX509TrustManager() { |
|
1530 |
// empty |
|
1531 |
} |
|
1532 |
||
1533 |
/* |
|
1534 |
* Given the partial or complete certificate chain |
|
1535 |
* provided by the peer, build a certificate path |
|
1536 |
* to a trusted root and return if it can be |
|
1537 |
* validated and is trusted for client SSL authentication. |
|
1538 |
* If not, it throws an exception. |
|
1539 |
*/ |
|
7043 | 1540 |
@Override |
2 | 1541 |
public void checkClientTrusted(X509Certificate[] chain, String authType) |
1542 |
throws CertificateException { |
|
1543 |
throw new CertificateException( |
|
1544 |
"No X509TrustManager implementation avaiable"); |
|
1545 |
} |
|
1546 |
||
1547 |
/* |
|
1548 |
* Given the partial or complete certificate chain |
|
1549 |
* provided by the peer, build a certificate path |
|
1550 |
* to a trusted root and return if it can be |
|
1551 |
* validated and is trusted for server SSL authentication. |
|
1552 |
* If not, it throws an exception. |
|
1553 |
*/ |
|
7043 | 1554 |
@Override |
2 | 1555 |
public void checkServerTrusted(X509Certificate[] chain, String authType) |
1556 |
throws CertificateException { |
|
1557 |
throw new CertificateException( |
|
1558 |
"No X509TrustManager implementation available"); |
|
1559 |
} |
|
1560 |
||
1561 |
/* |
|
1562 |
* Return an array of issuer certificates which are trusted |
|
1563 |
* for authenticating peers. |
|
1564 |
*/ |
|
7043 | 1565 |
@Override |
2 | 1566 |
public X509Certificate[] getAcceptedIssuers() { |
1567 |
return new X509Certificate[0]; |
|
1568 |
} |
|
7043 | 1569 |
|
1570 |
@Override |
|
1571 |
public void checkClientTrusted(X509Certificate[] chain, String authType, |
|
1572 |
Socket socket) throws CertificateException { |
|
1573 |
throw new CertificateException( |
|
1574 |
"No X509TrustManager implementation available"); |
|
1575 |
} |
|
1576 |
||
1577 |
@Override |
|
1578 |
public void checkServerTrusted(X509Certificate[] chain, String authType, |
|
1579 |
Socket socket) throws CertificateException { |
|
1580 |
throw new CertificateException( |
|
1581 |
"No X509TrustManager implementation available"); |
|
1582 |
} |
|
1583 |
||
1584 |
@Override |
|
1585 |
public void checkClientTrusted(X509Certificate[] chain, String authType, |
|
1586 |
SSLEngine engine) throws CertificateException { |
|
1587 |
throw new CertificateException( |
|
1588 |
"No X509TrustManager implementation available"); |
|
1589 |
} |
|
1590 |
||
1591 |
@Override |
|
1592 |
public void checkServerTrusted(X509Certificate[] chain, String authType, |
|
1593 |
SSLEngine engine) throws CertificateException { |
|
1594 |
throw new CertificateException( |
|
1595 |
"No X509TrustManager implementation available"); |
|
1596 |
} |
|
2 | 1597 |
} |
1598 |
||
1599 |
/* |
|
1600 |
* A wrapper class to turn a X509KeyManager into an X509ExtendedKeyManager |
|
1601 |
*/ |
|
7043 | 1602 |
final class AbstractKeyManagerWrapper extends X509ExtendedKeyManager { |
2 | 1603 |
|
1604 |
private final X509KeyManager km; |
|
1605 |
||
7043 | 1606 |
AbstractKeyManagerWrapper(X509KeyManager km) { |
2 | 1607 |
this.km = km; |
1608 |
} |
|
1609 |
||
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
13815
diff
changeset
|
1610 |
@Override |
2 | 1611 |
public String[] getClientAliases(String keyType, Principal[] issuers) { |
1612 |
return km.getClientAliases(keyType, issuers); |
|
1613 |
} |
|
1614 |
||
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
13815
diff
changeset
|
1615 |
@Override |
2 | 1616 |
public String chooseClientAlias(String[] keyType, Principal[] issuers, |
1617 |
Socket socket) { |
|
1618 |
return km.chooseClientAlias(keyType, issuers, socket); |
|
1619 |
} |
|
1620 |
||
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
13815
diff
changeset
|
1621 |
@Override |
2 | 1622 |
public String[] getServerAliases(String keyType, Principal[] issuers) { |
1623 |
return km.getServerAliases(keyType, issuers); |
|
1624 |
} |
|
1625 |
||
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
13815
diff
changeset
|
1626 |
@Override |
2 | 1627 |
public String chooseServerAlias(String keyType, Principal[] issuers, |
1628 |
Socket socket) { |
|
1629 |
return km.chooseServerAlias(keyType, issuers, socket); |
|
1630 |
} |
|
1631 |
||
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
13815
diff
changeset
|
1632 |
@Override |
2 | 1633 |
public X509Certificate[] getCertificateChain(String alias) { |
1634 |
return km.getCertificateChain(alias); |
|
1635 |
} |
|
1636 |
||
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
13815
diff
changeset
|
1637 |
@Override |
2 | 1638 |
public PrivateKey getPrivateKey(String alias) { |
1639 |
return km.getPrivateKey(alias); |
|
1640 |
} |
|
1641 |
||
1642 |
// Inherit chooseEngineClientAlias() and chooseEngineServerAlias() from |
|
1643 |
// X509ExtendedKeymanager. It defines them to return null; |
|
1644 |
} |
|
1645 |
||
1646 |
||
1647 |
// Dummy X509KeyManager implementation, never returns any certificates/keys. |
|
1648 |
// Used if the application did not specify a proper X509TrustManager. |
|
1649 |
final class DummyX509KeyManager extends X509ExtendedKeyManager { |
|
1650 |
||
1651 |
static final X509ExtendedKeyManager INSTANCE = new DummyX509KeyManager(); |
|
1652 |
||
1653 |
private DummyX509KeyManager() { |
|
1654 |
// empty |
|
1655 |
} |
|
1656 |
||
1657 |
/* |
|
1658 |
* Get the matching aliases for authenticating the client side of a secure |
|
1659 |
* socket given the public key type and the list of |
|
1660 |
* certificate issuer authorities recognized by the peer (if any). |
|
1661 |
*/ |
|
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
13815
diff
changeset
|
1662 |
@Override |
2 | 1663 |
public String[] getClientAliases(String keyType, Principal[] issuers) { |
1664 |
return null; |
|
1665 |
} |
|
1666 |
||
1667 |
/* |
|
1668 |
* Choose an alias to authenticate the client side of a secure |
|
1669 |
* socket given the public key type and the list of |
|
1670 |
* certificate issuer authorities recognized by the peer (if any). |
|
1671 |
*/ |
|
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
13815
diff
changeset
|
1672 |
@Override |
2 | 1673 |
public String chooseClientAlias(String[] keyTypes, Principal[] issuers, |
1674 |
Socket socket) { |
|
1675 |
return null; |
|
1676 |
} |
|
1677 |
||
1678 |
/* |
|
1679 |
* Choose an alias to authenticate the client side of an |
|
1680 |
* engine given the public key type and the list of |
|
1681 |
* certificate issuer authorities recognized by the peer (if any). |
|
1682 |
*/ |
|
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
13815
diff
changeset
|
1683 |
@Override |
2 | 1684 |
public String chooseEngineClientAlias( |
1685 |
String[] keyTypes, Principal[] issuers, SSLEngine engine) { |
|
1686 |
return null; |
|
1687 |
} |
|
1688 |
||
1689 |
/* |
|
1690 |
* Get the matching aliases for authenticating the server side of a secure |
|
1691 |
* socket given the public key type and the list of |
|
1692 |
* certificate issuer authorities recognized by the peer (if any). |
|
1693 |
*/ |
|
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
13815
diff
changeset
|
1694 |
@Override |
2 | 1695 |
public String[] getServerAliases(String keyType, Principal[] issuers) { |
1696 |
return null; |
|
1697 |
} |
|
1698 |
||
1699 |
/* |
|
1700 |
* Choose an alias to authenticate the server side of a secure |
|
1701 |
* socket given the public key type and the list of |
|
1702 |
* certificate issuer authorities recognized by the peer (if any). |
|
1703 |
*/ |
|
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
13815
diff
changeset
|
1704 |
@Override |
2 | 1705 |
public String chooseServerAlias(String keyType, Principal[] issuers, |
1706 |
Socket socket) { |
|
1707 |
return null; |
|
1708 |
} |
|
1709 |
||
1710 |
/* |
|
1711 |
* Choose an alias to authenticate the server side of an engine |
|
1712 |
* given the public key type and the list of |
|
1713 |
* certificate issuer authorities recognized by the peer (if any). |
|
1714 |
*/ |
|
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
13815
diff
changeset
|
1715 |
@Override |
2 | 1716 |
public String chooseEngineServerAlias( |
1717 |
String keyType, Principal[] issuers, SSLEngine engine) { |
|
1718 |
return null; |
|
1719 |
} |
|
1720 |
||
1721 |
/** |
|
1722 |
* Returns the certificate chain associated with the given alias. |
|
1723 |
* |
|
1724 |
* @param alias the alias name |
|
1725 |
* |
|
1726 |
* @return the certificate chain (ordered with the user's certificate first |
|
1727 |
* and the root certificate authority last) |
|
1728 |
*/ |
|
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
13815
diff
changeset
|
1729 |
@Override |
2 | 1730 |
public X509Certificate[] getCertificateChain(String alias) { |
1731 |
return null; |
|
1732 |
} |
|
1733 |
||
1734 |
/* |
|
1735 |
* Returns the key associated with the given alias, using the given |
|
1736 |
* password to recover it. |
|
1737 |
* |
|
1738 |
* @param alias the alias name |
|
1739 |
* |
|
1740 |
* @return the requested key |
|
1741 |
*/ |
|
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
13815
diff
changeset
|
1742 |
@Override |
2 | 1743 |
public PrivateKey getPrivateKey(String alias) { |
1744 |
return null; |
|
1745 |
} |
|
1746 |
} |