author | chegar |
Sun, 17 Aug 2014 15:54:13 +0100 | |
changeset 25859 | 3317bb8137f4 |
parent 22068 | jdk/src/share/classes/sun/security/ssl/SSLContextImpl.java@95a7a3cd72a0 |
child 28555 | c7bf34f7b215 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
22068 | 2 |
* Copyright (c) 1999, 2013, 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; |
7043 | 40 |
|
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
41 |
public abstract class SSLContextImpl extends SSLContextSpi { |
2 | 42 |
|
43 |
private static final Debug debug = Debug.getInstance("ssl"); |
|
44 |
||
45 |
private final EphemeralKeyManager ephemeralKeyManager; |
|
46 |
private final SSLSessionContextImpl clientCache; |
|
47 |
private final SSLSessionContextImpl serverCache; |
|
48 |
||
49 |
private boolean isInitialized; |
|
50 |
||
51 |
private X509ExtendedKeyManager keyManager; |
|
52 |
private X509TrustManager trustManager; |
|
53 |
private SecureRandom secureRandom; |
|
54 |
||
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
55 |
// The default algrithm constraints |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
56 |
private AlgorithmConstraints defaultAlgorithmConstraints = |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
57 |
new SSLAlgorithmConstraints(null); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
58 |
|
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
59 |
// supported and default protocols |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
60 |
private ProtocolList defaultServerProtocolList; |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
61 |
private ProtocolList defaultClientProtocolList; |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
62 |
private ProtocolList supportedProtocolList; |
2 | 63 |
|
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
64 |
// supported and default cipher suites |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
65 |
private CipherSuiteList defaultServerCipherSuiteList; |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
66 |
private CipherSuiteList defaultClientCipherSuiteList; |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
67 |
private CipherSuiteList supportedCipherSuiteList; |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
68 |
|
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
69 |
SSLContextImpl() { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
70 |
ephemeralKeyManager = new EphemeralKeyManager(); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
71 |
clientCache = new SSLSessionContextImpl(); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
72 |
serverCache = new SSLSessionContextImpl(); |
2 | 73 |
} |
74 |
||
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
13815
diff
changeset
|
75 |
@Override |
2 | 76 |
protected void engineInit(KeyManager[] km, TrustManager[] tm, |
77 |
SecureRandom sr) throws KeyManagementException { |
|
78 |
isInitialized = false; |
|
79 |
keyManager = chooseKeyManager(km); |
|
80 |
||
81 |
if (tm == null) { |
|
82 |
try { |
|
83 |
TrustManagerFactory tmf = TrustManagerFactory.getInstance( |
|
84 |
TrustManagerFactory.getDefaultAlgorithm()); |
|
85 |
tmf.init((KeyStore)null); |
|
86 |
tm = tmf.getTrustManagers(); |
|
87 |
} catch (Exception e) { |
|
88 |
// eat |
|
89 |
} |
|
90 |
} |
|
91 |
trustManager = chooseTrustManager(tm); |
|
92 |
||
93 |
if (sr == null) { |
|
94 |
secureRandom = JsseJce.getSecureRandom(); |
|
95 |
} else { |
|
7043 | 96 |
if (SunJSSE.isFIPS() && |
97 |
(sr.getProvider() != SunJSSE.cryptoProvider)) { |
|
2 | 98 |
throw new KeyManagementException |
99 |
("FIPS mode: SecureRandom must be from provider " |
|
100 |
+ SunJSSE.cryptoProvider.getName()); |
|
101 |
} |
|
102 |
secureRandom = sr; |
|
103 |
} |
|
104 |
||
105 |
/* |
|
106 |
* The initial delay of seeding the random number generator |
|
107 |
* could be long enough to cause the initial handshake on our |
|
108 |
* first connection to timeout and fail. Make sure it is |
|
109 |
* primed and ready by getting some initial output from it. |
|
110 |
*/ |
|
111 |
if (debug != null && Debug.isOn("sslctx")) { |
|
112 |
System.out.println("trigger seeding of SecureRandom"); |
|
113 |
} |
|
114 |
secureRandom.nextInt(); |
|
115 |
if (debug != null && Debug.isOn("sslctx")) { |
|
116 |
System.out.println("done seeding SecureRandom"); |
|
117 |
} |
|
118 |
isInitialized = true; |
|
119 |
} |
|
120 |
||
121 |
private X509TrustManager chooseTrustManager(TrustManager[] tm) |
|
122 |
throws KeyManagementException { |
|
123 |
// We only use the first instance of X509TrustManager passed to us. |
|
124 |
for (int i = 0; tm != null && i < tm.length; i++) { |
|
125 |
if (tm[i] instanceof X509TrustManager) { |
|
7043 | 126 |
if (SunJSSE.isFIPS() && |
127 |
!(tm[i] instanceof X509TrustManagerImpl)) { |
|
2 | 128 |
throw new KeyManagementException |
129 |
("FIPS mode: only SunJSSE TrustManagers may be used"); |
|
130 |
} |
|
7043 | 131 |
|
132 |
if (tm[i] instanceof X509ExtendedTrustManager) { |
|
133 |
return (X509TrustManager)tm[i]; |
|
134 |
} else { |
|
135 |
return new AbstractTrustManagerWrapper( |
|
136 |
(X509TrustManager)tm[i]); |
|
137 |
} |
|
2 | 138 |
} |
139 |
} |
|
140 |
||
141 |
// nothing found, return a dummy X509TrustManager. |
|
142 |
return DummyX509TrustManager.INSTANCE; |
|
143 |
} |
|
144 |
||
145 |
private X509ExtendedKeyManager chooseKeyManager(KeyManager[] kms) |
|
146 |
throws KeyManagementException { |
|
147 |
for (int i = 0; kms != null && i < kms.length; i++) { |
|
148 |
KeyManager km = kms[i]; |
|
12874 | 149 |
if (!(km instanceof X509KeyManager)) { |
2 | 150 |
continue; |
151 |
} |
|
152 |
if (SunJSSE.isFIPS()) { |
|
153 |
// In FIPS mode, require that one of SunJSSE's own keymanagers |
|
154 |
// is used. Otherwise, we cannot be sure that only keys from |
|
155 |
// the FIPS token are used. |
|
156 |
if ((km instanceof X509KeyManagerImpl) |
|
157 |
|| (km instanceof SunX509KeyManagerImpl)) { |
|
158 |
return (X509ExtendedKeyManager)km; |
|
159 |
} else { |
|
160 |
// throw exception, we don't want to silently use the |
|
161 |
// dummy keymanager without telling the user. |
|
162 |
throw new KeyManagementException |
|
163 |
("FIPS mode: only SunJSSE KeyManagers may be used"); |
|
164 |
} |
|
165 |
} |
|
166 |
if (km instanceof X509ExtendedKeyManager) { |
|
167 |
return (X509ExtendedKeyManager)km; |
|
168 |
} |
|
169 |
if (debug != null && Debug.isOn("sslctx")) { |
|
170 |
System.out.println( |
|
171 |
"X509KeyManager passed to " + |
|
172 |
"SSLContext.init(): need an " + |
|
173 |
"X509ExtendedKeyManager for SSLEngine use"); |
|
174 |
} |
|
7043 | 175 |
return new AbstractKeyManagerWrapper((X509KeyManager)km); |
2 | 176 |
} |
177 |
||
178 |
// nothing found, return a dummy X509ExtendedKeyManager |
|
179 |
return DummyX509KeyManager.INSTANCE; |
|
180 |
} |
|
181 |
||
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
13815
diff
changeset
|
182 |
@Override |
2 | 183 |
protected SSLSocketFactory engineGetSocketFactory() { |
184 |
if (!isInitialized) { |
|
185 |
throw new IllegalStateException( |
|
186 |
"SSLContextImpl is not initialized"); |
|
187 |
} |
|
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
188 |
return new SSLSocketFactoryImpl(this); |
2 | 189 |
} |
190 |
||
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
13815
diff
changeset
|
191 |
@Override |
2 | 192 |
protected SSLServerSocketFactory engineGetServerSocketFactory() { |
193 |
if (!isInitialized) { |
|
194 |
throw new IllegalStateException("SSLContext is not initialized"); |
|
195 |
} |
|
196 |
return new SSLServerSocketFactoryImpl(this); |
|
197 |
} |
|
198 |
||
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
13815
diff
changeset
|
199 |
@Override |
2 | 200 |
protected SSLEngine engineCreateSSLEngine() { |
201 |
if (!isInitialized) { |
|
202 |
throw new IllegalStateException( |
|
203 |
"SSLContextImpl is not initialized"); |
|
204 |
} |
|
205 |
return new SSLEngineImpl(this); |
|
206 |
} |
|
207 |
||
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
13815
diff
changeset
|
208 |
@Override |
2 | 209 |
protected SSLEngine engineCreateSSLEngine(String host, int port) { |
210 |
if (!isInitialized) { |
|
211 |
throw new IllegalStateException( |
|
212 |
"SSLContextImpl is not initialized"); |
|
213 |
} |
|
214 |
return new SSLEngineImpl(this, host, port); |
|
215 |
} |
|
216 |
||
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
13815
diff
changeset
|
217 |
@Override |
2 | 218 |
protected SSLSessionContext engineGetClientSessionContext() { |
219 |
return clientCache; |
|
220 |
} |
|
221 |
||
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
13815
diff
changeset
|
222 |
@Override |
2 | 223 |
protected SSLSessionContext engineGetServerSessionContext() { |
224 |
return serverCache; |
|
225 |
} |
|
226 |
||
227 |
SecureRandom getSecureRandom() { |
|
228 |
return secureRandom; |
|
229 |
} |
|
230 |
||
231 |
X509ExtendedKeyManager getX509KeyManager() { |
|
232 |
return keyManager; |
|
233 |
} |
|
234 |
||
235 |
X509TrustManager getX509TrustManager() { |
|
236 |
return trustManager; |
|
237 |
} |
|
238 |
||
239 |
EphemeralKeyManager getEphemeralKeyManager() { |
|
240 |
return ephemeralKeyManager; |
|
241 |
} |
|
242 |
||
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
243 |
abstract SSLParameters getDefaultServerSSLParams(); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
244 |
abstract SSLParameters getDefaultClientSSLParams(); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
245 |
abstract SSLParameters getSupportedSSLParams(); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
246 |
|
21278 | 247 |
// Get supported ProtocolList. |
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
248 |
ProtocolList getSuportedProtocolList() { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
249 |
if (supportedProtocolList == null) { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
250 |
supportedProtocolList = |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
251 |
new ProtocolList(getSupportedSSLParams().getProtocols()); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
252 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
253 |
|
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
254 |
return supportedProtocolList; |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
255 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
256 |
|
21278 | 257 |
// Get default ProtocolList. |
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
258 |
ProtocolList getDefaultProtocolList(boolean roleIsServer) { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
259 |
if (roleIsServer) { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
260 |
if (defaultServerProtocolList == null) { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
261 |
defaultServerProtocolList = new ProtocolList( |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
262 |
getDefaultServerSSLParams().getProtocols()); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
263 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
264 |
|
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
265 |
return defaultServerProtocolList; |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
266 |
} else { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
267 |
if (defaultClientProtocolList == null) { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
268 |
defaultClientProtocolList = new ProtocolList( |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
269 |
getDefaultClientSSLParams().getProtocols()); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
270 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
271 |
|
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
272 |
return defaultClientProtocolList; |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
273 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
274 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
275 |
|
21278 | 276 |
// Get supported CipherSuiteList. |
13815 | 277 |
CipherSuiteList getSupportedCipherSuiteList() { |
12671
729f78ba3a10
7153184: NullPointerException when calling SSLEngineImpl.getSupportedCipherSuites
xuelei
parents:
12302
diff
changeset
|
278 |
// The maintenance of cipher suites needs to be synchronized. |
729f78ba3a10
7153184: NullPointerException when calling SSLEngineImpl.getSupportedCipherSuites
xuelei
parents:
12302
diff
changeset
|
279 |
synchronized (this) { |
729f78ba3a10
7153184: NullPointerException when calling SSLEngineImpl.getSupportedCipherSuites
xuelei
parents:
12302
diff
changeset
|
280 |
// Clear cache of available ciphersuites. |
729f78ba3a10
7153184: NullPointerException when calling SSLEngineImpl.getSupportedCipherSuites
xuelei
parents:
12302
diff
changeset
|
281 |
clearAvailableCache(); |
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
282 |
|
12671
729f78ba3a10
7153184: NullPointerException when calling SSLEngineImpl.getSupportedCipherSuites
xuelei
parents:
12302
diff
changeset
|
283 |
if (supportedCipherSuiteList == null) { |
729f78ba3a10
7153184: NullPointerException when calling SSLEngineImpl.getSupportedCipherSuites
xuelei
parents:
12302
diff
changeset
|
284 |
supportedCipherSuiteList = getApplicableCipherSuiteList( |
729f78ba3a10
7153184: NullPointerException when calling SSLEngineImpl.getSupportedCipherSuites
xuelei
parents:
12302
diff
changeset
|
285 |
getSuportedProtocolList(), false); |
729f78ba3a10
7153184: NullPointerException when calling SSLEngineImpl.getSupportedCipherSuites
xuelei
parents:
12302
diff
changeset
|
286 |
} |
12677
2b25f3fc4f81
7167092: Need to put the return clause in the synchronized block
xuelei
parents:
12671
diff
changeset
|
287 |
|
2b25f3fc4f81
7167092: Need to put the return clause in the synchronized block
xuelei
parents:
12671
diff
changeset
|
288 |
return supportedCipherSuiteList; |
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
289 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
290 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
291 |
|
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
292 |
// Get default CipherSuiteList. |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
293 |
CipherSuiteList getDefaultCipherSuiteList(boolean roleIsServer) { |
12677
2b25f3fc4f81
7167092: Need to put the return clause in the synchronized block
xuelei
parents:
12671
diff
changeset
|
294 |
// The maintenance of cipher suites needs to be synchronized. |
2b25f3fc4f81
7167092: Need to put the return clause in the synchronized block
xuelei
parents:
12671
diff
changeset
|
295 |
synchronized (this) { |
2b25f3fc4f81
7167092: Need to put the return clause in the synchronized block
xuelei
parents:
12671
diff
changeset
|
296 |
// Clear cache of available ciphersuites. |
2b25f3fc4f81
7167092: Need to put the return clause in the synchronized block
xuelei
parents:
12671
diff
changeset
|
297 |
clearAvailableCache(); |
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
298 |
|
12677
2b25f3fc4f81
7167092: Need to put the return clause in the synchronized block
xuelei
parents:
12671
diff
changeset
|
299 |
if (roleIsServer) { |
12671
729f78ba3a10
7153184: NullPointerException when calling SSLEngineImpl.getSupportedCipherSuites
xuelei
parents:
12302
diff
changeset
|
300 |
if (defaultServerCipherSuiteList == null) { |
729f78ba3a10
7153184: NullPointerException when calling SSLEngineImpl.getSupportedCipherSuites
xuelei
parents:
12302
diff
changeset
|
301 |
defaultServerCipherSuiteList = getApplicableCipherSuiteList( |
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
302 |
getDefaultProtocolList(true), true); |
12671
729f78ba3a10
7153184: NullPointerException when calling SSLEngineImpl.getSupportedCipherSuites
xuelei
parents:
12302
diff
changeset
|
303 |
} |
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
304 |
|
12677
2b25f3fc4f81
7167092: Need to put the return clause in the synchronized block
xuelei
parents:
12671
diff
changeset
|
305 |
return defaultServerCipherSuiteList; |
2b25f3fc4f81
7167092: Need to put the return clause in the synchronized block
xuelei
parents:
12671
diff
changeset
|
306 |
} else { |
12671
729f78ba3a10
7153184: NullPointerException when calling SSLEngineImpl.getSupportedCipherSuites
xuelei
parents:
12302
diff
changeset
|
307 |
if (defaultClientCipherSuiteList == null) { |
729f78ba3a10
7153184: NullPointerException when calling SSLEngineImpl.getSupportedCipherSuites
xuelei
parents:
12302
diff
changeset
|
308 |
defaultClientCipherSuiteList = getApplicableCipherSuiteList( |
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
309 |
getDefaultProtocolList(false), true); |
12671
729f78ba3a10
7153184: NullPointerException when calling SSLEngineImpl.getSupportedCipherSuites
xuelei
parents:
12302
diff
changeset
|
310 |
} |
12677
2b25f3fc4f81
7167092: Need to put the return clause in the synchronized block
xuelei
parents:
12671
diff
changeset
|
311 |
|
2b25f3fc4f81
7167092: Need to put the return clause in the synchronized block
xuelei
parents:
12671
diff
changeset
|
312 |
return defaultClientCipherSuiteList; |
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 |
|
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
317 |
/** |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
318 |
* 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
|
319 |
* protocols. See: SSLSocket/SSLEngine.setEnabledProtocols() |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
320 |
*/ |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
321 |
boolean isDefaultProtocolList(ProtocolList protocols) { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
322 |
return (protocols == defaultServerProtocolList) || |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
323 |
(protocols == defaultClientProtocolList); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
324 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
325 |
|
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
326 |
|
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
327 |
/* |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
328 |
* Return the list of all available CipherSuites with a priority of |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
329 |
* minPriority or above. |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
330 |
*/ |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
331 |
private CipherSuiteList getApplicableCipherSuiteList( |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
332 |
ProtocolList protocols, boolean onlyEnabled) { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
333 |
|
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
334 |
int minPriority = CipherSuite.SUPPORTED_SUITES_PRIORITY; |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
335 |
if (onlyEnabled) { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
336 |
minPriority = CipherSuite.DEFAULT_SUITES_PRIORITY; |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
337 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
338 |
|
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
339 |
Collection<CipherSuite> allowedCipherSuites = |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
340 |
CipherSuite.allowedCipherSuites(); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
341 |
|
12874 | 342 |
TreeSet<CipherSuite> suites = new TreeSet<>(); |
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
343 |
if (!(protocols.collection().isEmpty()) && |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
344 |
protocols.min.v != ProtocolVersion.NONE.v) { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
345 |
for (CipherSuite suite : allowedCipherSuites) { |
12874 | 346 |
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
|
347 |
continue; |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
348 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
349 |
|
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
350 |
if (suite.isAvailable() && |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
351 |
suite.obsoleted > protocols.min.v && |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
352 |
suite.supported <= protocols.max.v) { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
353 |
if (defaultAlgorithmConstraints.permits( |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
354 |
EnumSet.of(CryptoPrimitive.KEY_AGREEMENT), |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
355 |
suite.name, null)) { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
356 |
suites.add(suite); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
357 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
358 |
} else if (debug != null && |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
359 |
Debug.isOn("sslctx") && Debug.isOn("verbose")) { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
360 |
if (suite.obsoleted <= protocols.min.v) { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
361 |
System.out.println( |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
362 |
"Ignoring obsoleted cipher suite: " + suite); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
363 |
} else if (suite.supported > protocols.max.v) { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
364 |
System.out.println( |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
365 |
"Ignoring unsupported cipher suite: " + suite); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
366 |
} else { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
367 |
System.out.println( |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
368 |
"Ignoring unavailable cipher suite: " + suite); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
369 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
370 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
371 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
372 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
373 |
|
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
374 |
return new CipherSuiteList(suites); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
375 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
376 |
|
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
377 |
/** |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
378 |
* Clear cache of available ciphersuites. If we support all ciphers |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
379 |
* internally, there is no need to clear the cache and calling this |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
380 |
* method has no effect. |
12671
729f78ba3a10
7153184: NullPointerException when calling SSLEngineImpl.getSupportedCipherSuites
xuelei
parents:
12302
diff
changeset
|
381 |
* |
729f78ba3a10
7153184: NullPointerException when calling SSLEngineImpl.getSupportedCipherSuites
xuelei
parents:
12302
diff
changeset
|
382 |
* Note that every call to clearAvailableCache() and the maintenance of |
729f78ba3a10
7153184: NullPointerException when calling SSLEngineImpl.getSupportedCipherSuites
xuelei
parents:
12302
diff
changeset
|
383 |
* cipher suites need to be synchronized with this instance. |
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
384 |
*/ |
12671
729f78ba3a10
7153184: NullPointerException when calling SSLEngineImpl.getSupportedCipherSuites
xuelei
parents:
12302
diff
changeset
|
385 |
private void clearAvailableCache() { |
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
386 |
if (CipherSuite.DYNAMIC_AVAILABILITY) { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
387 |
supportedCipherSuiteList = null; |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
388 |
defaultServerCipherSuiteList = null; |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
389 |
defaultClientCipherSuiteList = null; |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
390 |
CipherSuite.BulkCipher.clearAvailableCache(); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
391 |
JsseJce.clearEcAvailable(); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
392 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
393 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
394 |
|
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
395 |
/* |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
396 |
* The SSLContext implementation for TLS/SSL algorithm |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
397 |
* |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
398 |
* 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
|
399 |
* 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
|
400 |
* 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
|
401 |
* 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
|
402 |
* |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
403 |
* 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
|
404 |
* 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
|
405 |
* |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
406 |
* 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
|
407 |
* 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
|
408 |
* enabled protocols for server by default. |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
409 |
* |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
410 |
* 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
|
411 |
* forward compatibility properly. |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
412 |
* |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
413 |
* 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
|
414 |
* 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
|
415 |
* 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
|
416 |
* 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
|
417 |
* 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
|
418 |
* |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
419 |
* 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
|
420 |
* 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
|
421 |
* the series of setEnabledProtocols APIs. |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
422 |
*/ |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
423 |
|
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
424 |
/* |
22068 | 425 |
* The base abstract SSLContext implementation. |
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
426 |
* |
22068 | 427 |
* This abstract class encapsulates supported and the default server |
428 |
* SSL parameters. |
|
9246
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 |
* @see SSLContext |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
431 |
*/ |
22068 | 432 |
private abstract static class AbstractSSLContext extends SSLContextImpl { |
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
433 |
// parameters |
22068 | 434 |
private final static SSLParameters defaultServerSSLParams; |
435 |
private final static SSLParameters supportedSSLParams; |
|
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
436 |
|
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
437 |
static { |
22068 | 438 |
supportedSSLParams = new SSLParameters(); |
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
439 |
if (SunJSSE.isFIPS()) { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
440 |
supportedSSLParams.setProtocols(new String[] { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
441 |
ProtocolVersion.TLS10.name, |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
442 |
ProtocolVersion.TLS11.name, |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
443 |
ProtocolVersion.TLS12.name |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
444 |
}); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
445 |
|
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
446 |
defaultServerSSLParams = supportedSSLParams; |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
447 |
} else { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
448 |
supportedSSLParams.setProtocols(new String[] { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
449 |
ProtocolVersion.SSL20Hello.name, |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
450 |
ProtocolVersion.SSL30.name, |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
451 |
ProtocolVersion.TLS10.name, |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
452 |
ProtocolVersion.TLS11.name, |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
453 |
ProtocolVersion.TLS12.name |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
454 |
}); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
455 |
|
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
456 |
defaultServerSSLParams = supportedSSLParams; |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
457 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
458 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
459 |
|
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
13815
diff
changeset
|
460 |
@Override |
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
461 |
SSLParameters getDefaultServerSSLParams() { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
462 |
return defaultServerSSLParams; |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
463 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
464 |
|
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
13815
diff
changeset
|
465 |
@Override |
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
466 |
SSLParameters getSupportedSSLParams() { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
467 |
return supportedSSLParams; |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
468 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
469 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
470 |
|
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
471 |
/* |
22068 | 472 |
* The SSLContext implementation for SSLv3 and TLS10 algorithm |
473 |
* |
|
474 |
* @see SSLContext |
|
475 |
*/ |
|
476 |
public static final class TLS10Context extends AbstractSSLContext { |
|
477 |
private final static SSLParameters defaultClientSSLParams; |
|
478 |
||
479 |
static { |
|
480 |
defaultClientSSLParams = new SSLParameters(); |
|
481 |
if (SunJSSE.isFIPS()) { |
|
482 |
defaultClientSSLParams.setProtocols(new String[] { |
|
483 |
ProtocolVersion.TLS10.name |
|
484 |
}); |
|
485 |
||
486 |
} else { |
|
487 |
defaultClientSSLParams.setProtocols(new String[] { |
|
488 |
ProtocolVersion.SSL30.name, |
|
489 |
ProtocolVersion.TLS10.name |
|
490 |
}); |
|
491 |
} |
|
492 |
} |
|
493 |
||
494 |
@Override |
|
495 |
SSLParameters getDefaultClientSSLParams() { |
|
496 |
return defaultClientSSLParams; |
|
497 |
} |
|
498 |
} |
|
499 |
||
500 |
/* |
|
501 |
* The SSLContext implementation for TLS11 algorithm |
|
502 |
* |
|
503 |
* @see SSLContext |
|
504 |
*/ |
|
505 |
public static final class TLS11Context extends AbstractSSLContext { |
|
506 |
private final static SSLParameters defaultClientSSLParams; |
|
507 |
||
508 |
static { |
|
509 |
defaultClientSSLParams = new SSLParameters(); |
|
510 |
if (SunJSSE.isFIPS()) { |
|
511 |
defaultClientSSLParams.setProtocols(new String[] { |
|
512 |
ProtocolVersion.TLS10.name, |
|
513 |
ProtocolVersion.TLS11.name |
|
514 |
}); |
|
515 |
||
516 |
} else { |
|
517 |
defaultClientSSLParams.setProtocols(new String[] { |
|
518 |
ProtocolVersion.SSL30.name, |
|
519 |
ProtocolVersion.TLS10.name, |
|
520 |
ProtocolVersion.TLS11.name |
|
521 |
}); |
|
522 |
} |
|
523 |
} |
|
524 |
||
525 |
@Override |
|
526 |
SSLParameters getDefaultClientSSLParams() { |
|
527 |
return defaultClientSSLParams; |
|
528 |
} |
|
529 |
} |
|
530 |
||
531 |
/* |
|
532 |
* The SSLContext implementation for TLS12 algorithm |
|
533 |
* |
|
534 |
* @see SSLContext |
|
535 |
*/ |
|
536 |
public static final class TLS12Context extends AbstractSSLContext { |
|
537 |
private final static SSLParameters defaultClientSSLParams; |
|
538 |
||
539 |
static { |
|
540 |
defaultClientSSLParams = new SSLParameters(); |
|
541 |
if (SunJSSE.isFIPS()) { |
|
542 |
defaultClientSSLParams.setProtocols(new String[] { |
|
543 |
ProtocolVersion.TLS10.name, |
|
544 |
ProtocolVersion.TLS11.name, |
|
545 |
ProtocolVersion.TLS12.name |
|
546 |
}); |
|
547 |
||
548 |
} else { |
|
549 |
defaultClientSSLParams.setProtocols(new String[] { |
|
550 |
ProtocolVersion.SSL30.name, |
|
551 |
ProtocolVersion.TLS10.name, |
|
552 |
ProtocolVersion.TLS11.name, |
|
553 |
ProtocolVersion.TLS12.name |
|
554 |
}); |
|
555 |
} |
|
556 |
} |
|
557 |
||
558 |
@Override |
|
559 |
SSLParameters getDefaultClientSSLParams() { |
|
560 |
return defaultClientSSLParams; |
|
561 |
} |
|
562 |
} |
|
563 |
||
564 |
/* |
|
565 |
* 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
|
566 |
* |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
567 |
* @see SSLContext |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
568 |
*/ |
22068 | 569 |
private static class CustomizedSSLContext extends AbstractSSLContext { |
570 |
private final static String PROPERTY_NAME = "jdk.tls.client.protocols"; |
|
571 |
private final static SSLParameters defaultClientSSLParams; |
|
572 |
private static IllegalArgumentException reservedException = null; |
|
573 |
||
574 |
// Don't want a java.lang.LinkageError for illegal system property. |
|
575 |
// |
|
576 |
// Please don't throw exception in this static block. Otherwise, |
|
577 |
// java.lang.LinkageError may be thrown during the instantiation of |
|
578 |
// the provider service. Instead, let's handle the initialization |
|
579 |
// exception in constructor. |
|
580 |
static { |
|
581 |
String property = AccessController.doPrivileged( |
|
582 |
new GetPropertyAction(PROPERTY_NAME)); |
|
583 |
defaultClientSSLParams = new SSLParameters(); |
|
584 |
if (property == null || property.length() == 0) { |
|
585 |
// the default enabled client TLS protocols |
|
586 |
if (SunJSSE.isFIPS()) { |
|
587 |
defaultClientSSLParams.setProtocols(new String[] { |
|
588 |
ProtocolVersion.TLS10.name, |
|
589 |
ProtocolVersion.TLS11.name, |
|
590 |
ProtocolVersion.TLS12.name |
|
591 |
}); |
|
592 |
||
593 |
} else { |
|
594 |
defaultClientSSLParams.setProtocols(new String[] { |
|
595 |
ProtocolVersion.SSL30.name, |
|
596 |
ProtocolVersion.TLS10.name, |
|
597 |
ProtocolVersion.TLS11.name, |
|
598 |
ProtocolVersion.TLS12.name |
|
599 |
}); |
|
600 |
} |
|
601 |
} else { |
|
602 |
// remove double quote marks from beginning/end of the property |
|
603 |
if (property.charAt(0) == '"' && |
|
604 |
property.charAt(property.length() - 1) == '"') { |
|
605 |
property = property.substring(1, property.length() - 1); |
|
606 |
} |
|
607 |
||
608 |
String[] protocols = property.split(","); |
|
609 |
for (int i = 0; i < protocols.length; i++) { |
|
610 |
protocols[i] = protocols[i].trim(); |
|
611 |
// Is it a supported protocol name? |
|
612 |
try { |
|
613 |
ProtocolVersion.valueOf(protocols[i]); |
|
614 |
} catch (IllegalArgumentException iae) { |
|
615 |
reservedException = new IllegalArgumentException( |
|
616 |
PROPERTY_NAME + ": " + protocols[i] + |
|
617 |
" is not a standard SSL protocol name", iae); |
|
618 |
} |
|
619 |
} |
|
620 |
||
621 |
if ((reservedException == null) && SunJSSE.isFIPS()) { |
|
622 |
for (String protocol : protocols) { |
|
623 |
if (ProtocolVersion.SSL20Hello.name.equals(protocol) || |
|
624 |
ProtocolVersion.SSL30.name.equals(protocol)) { |
|
625 |
reservedException = new IllegalArgumentException( |
|
626 |
PROPERTY_NAME + ": " + protocol + |
|
627 |
" is not FIPS compliant"); |
|
628 |
} |
|
629 |
} |
|
630 |
} |
|
631 |
||
632 |
if (reservedException == null) { |
|
633 |
defaultClientSSLParams.setProtocols(protocols); |
|
634 |
} |
|
635 |
} |
|
636 |
} |
|
637 |
||
638 |
protected CustomizedSSLContext() { |
|
639 |
if (reservedException != null) { |
|
640 |
throw reservedException; |
|
641 |
} |
|
642 |
} |
|
643 |
||
644 |
@Override |
|
645 |
SSLParameters getDefaultClientSSLParams() { |
|
646 |
return defaultClientSSLParams; |
|
647 |
} |
|
648 |
} |
|
649 |
||
650 |
/* |
|
651 |
* The SSLContext implementation for default "TLS" algorithm |
|
652 |
* |
|
653 |
* @see SSLContext |
|
654 |
*/ |
|
655 |
public static final class TLSContext extends CustomizedSSLContext { |
|
656 |
// use the default constructor and methods |
|
657 |
} |
|
658 |
||
659 |
/* |
|
660 |
* The SSLContext implementation for default "Default" algorithm |
|
661 |
* |
|
662 |
* @see SSLContext |
|
663 |
*/ |
|
664 |
public static final class DefaultSSLContext extends CustomizedSSLContext { |
|
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
665 |
private static final String NONE = "NONE"; |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
666 |
private static final String P11KEYSTORE = "PKCS11"; |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
667 |
|
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
668 |
private static volatile SSLContextImpl defaultImpl; |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
669 |
|
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
670 |
private static TrustManager[] defaultTrustManagers; |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
671 |
private static KeyManager[] defaultKeyManagers; |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
672 |
|
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
673 |
public DefaultSSLContext() throws Exception { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
674 |
try { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
675 |
super.engineInit(getDefaultKeyManager(), |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
676 |
getDefaultTrustManager(), null); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
677 |
} catch (Exception e) { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
678 |
if (debug != null && Debug.isOn("defaultctx")) { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
679 |
System.out.println("default context init failed: " + e); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
680 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
681 |
throw e; |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
682 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
683 |
|
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
684 |
if (defaultImpl == null) { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
685 |
defaultImpl = this; |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
686 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
687 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
688 |
|
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
13815
diff
changeset
|
689 |
@Override |
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
690 |
protected void engineInit(KeyManager[] km, TrustManager[] tm, |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
691 |
SecureRandom sr) throws KeyManagementException { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
692 |
throw new KeyManagementException |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
693 |
("Default SSLContext is initialized automatically"); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
694 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
695 |
|
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
696 |
static synchronized SSLContextImpl getDefaultImpl() throws Exception { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
697 |
if (defaultImpl == null) { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
698 |
new DefaultSSLContext(); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
699 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
700 |
return defaultImpl; |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
701 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
702 |
|
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
703 |
private static synchronized TrustManager[] getDefaultTrustManager() |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
704 |
throws Exception { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
705 |
if (defaultTrustManagers != null) { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
706 |
return defaultTrustManagers; |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
707 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
708 |
|
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
709 |
KeyStore ks = |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
710 |
TrustManagerFactoryImpl.getCacertsKeyStore("defaultctx"); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
711 |
|
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
712 |
TrustManagerFactory tmf = TrustManagerFactory.getInstance( |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
713 |
TrustManagerFactory.getDefaultAlgorithm()); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
714 |
tmf.init(ks); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
715 |
defaultTrustManagers = tmf.getTrustManagers(); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
716 |
return defaultTrustManagers; |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
717 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
718 |
|
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
719 |
private static synchronized KeyManager[] getDefaultKeyManager() |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
720 |
throws Exception { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
721 |
if (defaultKeyManagers != null) { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
722 |
return defaultKeyManagers; |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
723 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
724 |
|
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
725 |
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
|
726 |
AccessController.doPrivileged( |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
727 |
new PrivilegedExceptionAction<Object>() { |
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
13815
diff
changeset
|
728 |
@Override |
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
729 |
public Object run() throws Exception { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
730 |
props.put("keyStore", System.getProperty( |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
731 |
"javax.net.ssl.keyStore", "")); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
732 |
props.put("keyStoreType", System.getProperty( |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
733 |
"javax.net.ssl.keyStoreType", |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
734 |
KeyStore.getDefaultType())); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
735 |
props.put("keyStoreProvider", System.getProperty( |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
736 |
"javax.net.ssl.keyStoreProvider", "")); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
737 |
props.put("keyStorePasswd", System.getProperty( |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
738 |
"javax.net.ssl.keyStorePassword", "")); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
739 |
return null; |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
740 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
741 |
}); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
742 |
|
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
743 |
final String defaultKeyStore = props.get("keyStore"); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
744 |
String defaultKeyStoreType = props.get("keyStoreType"); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
745 |
String defaultKeyStoreProvider = props.get("keyStoreProvider"); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
746 |
if (debug != null && Debug.isOn("defaultctx")) { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
747 |
System.out.println("keyStore is : " + defaultKeyStore); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
748 |
System.out.println("keyStore type is : " + |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
749 |
defaultKeyStoreType); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
750 |
System.out.println("keyStore provider is : " + |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
751 |
defaultKeyStoreProvider); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
752 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
753 |
|
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
754 |
if (P11KEYSTORE.equals(defaultKeyStoreType) && |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
755 |
!NONE.equals(defaultKeyStore)) { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
756 |
throw new IllegalArgumentException("if keyStoreType is " |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
757 |
+ P11KEYSTORE + ", then keyStore must be " + NONE); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
758 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
759 |
|
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
760 |
FileInputStream fs = null; |
10125 | 761 |
KeyStore ks = null; |
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
762 |
char[] passwd = null; |
10125 | 763 |
try { |
764 |
if (defaultKeyStore.length() != 0 && |
|
765 |
!NONE.equals(defaultKeyStore)) { |
|
766 |
fs = AccessController.doPrivileged( |
|
767 |
new PrivilegedExceptionAction<FileInputStream>() { |
|
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
13815
diff
changeset
|
768 |
@Override |
10125 | 769 |
public FileInputStream run() throws Exception { |
770 |
return new FileInputStream(defaultKeyStore); |
|
771 |
} |
|
772 |
}); |
|
773 |
} |
|
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
774 |
|
10125 | 775 |
String defaultKeyStorePassword = props.get("keyStorePasswd"); |
776 |
if (defaultKeyStorePassword.length() != 0) { |
|
777 |
passwd = defaultKeyStorePassword.toCharArray(); |
|
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
778 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
779 |
|
10125 | 780 |
/** |
781 |
* Try to initialize key store. |
|
782 |
*/ |
|
783 |
if ((defaultKeyStoreType.length()) != 0) { |
|
784 |
if (debug != null && Debug.isOn("defaultctx")) { |
|
785 |
System.out.println("init keystore"); |
|
786 |
} |
|
787 |
if (defaultKeyStoreProvider.length() == 0) { |
|
788 |
ks = KeyStore.getInstance(defaultKeyStoreType); |
|
789 |
} else { |
|
790 |
ks = KeyStore.getInstance(defaultKeyStoreType, |
|
791 |
defaultKeyStoreProvider); |
|
792 |
} |
|
793 |
||
794 |
// if defaultKeyStore is NONE, fs will be null |
|
795 |
ks.load(fs, passwd); |
|
796 |
} |
|
797 |
} finally { |
|
798 |
if (fs != null) { |
|
799 |
fs.close(); |
|
800 |
fs = null; |
|
801 |
} |
|
9246
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
802 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
803 |
|
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
804 |
/* |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
805 |
* Try to initialize key manager. |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
806 |
*/ |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
807 |
if (debug != null && Debug.isOn("defaultctx")) { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
808 |
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
|
809 |
KeyManagerFactory.getDefaultAlgorithm()); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
810 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
811 |
KeyManagerFactory kmf = KeyManagerFactory.getInstance( |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
812 |
KeyManagerFactory.getDefaultAlgorithm()); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
813 |
|
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
814 |
if (P11KEYSTORE.equals(defaultKeyStoreType)) { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
815 |
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
|
816 |
} else { |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
817 |
kmf.init(ks, passwd); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
818 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
819 |
|
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
820 |
defaultKeyManagers = kmf.getKeyManagers(); |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
821 |
return defaultKeyManagers; |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
822 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
823 |
} |
c459f79af46b
6976117: SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets without TLSv1.1 enabled
xuelei
parents:
7043
diff
changeset
|
824 |
|
2 | 825 |
} |
826 |
||
7043 | 827 |
|
828 |
final class AbstractTrustManagerWrapper extends X509ExtendedTrustManager |
|
829 |
implements X509TrustManager { |
|
830 |
||
11037
03c29eb4afa0
7113275: compatibility issue with MD2 trust anchor and old X509TrustManager
xuelei
parents:
10125
diff
changeset
|
831 |
// the delegated trust manager |
7043 | 832 |
private final X509TrustManager tm; |
833 |
||
834 |
AbstractTrustManagerWrapper(X509TrustManager tm) { |
|
835 |
this.tm = tm; |
|
836 |
} |
|
837 |
||
838 |
@Override |
|
839 |
public void checkClientTrusted(X509Certificate[] chain, String authType) |
|
840 |
throws CertificateException { |
|
841 |
tm.checkClientTrusted(chain, authType); |
|
842 |
} |
|
843 |
||
844 |
@Override |
|
845 |
public void checkServerTrusted(X509Certificate[] chain, String authType) |
|
846 |
throws CertificateException { |
|
847 |
tm.checkServerTrusted(chain, authType); |
|
848 |
} |
|
849 |
||
850 |
@Override |
|
851 |
public X509Certificate[] getAcceptedIssuers() { |
|
852 |
return tm.getAcceptedIssuers(); |
|
853 |
} |
|
854 |
||
855 |
@Override |
|
856 |
public void checkClientTrusted(X509Certificate[] chain, String authType, |
|
857 |
Socket socket) throws CertificateException { |
|
858 |
tm.checkClientTrusted(chain, authType); |
|
859 |
checkAdditionalTrust(chain, authType, socket, true); |
|
860 |
} |
|
861 |
||
862 |
@Override |
|
863 |
public void checkServerTrusted(X509Certificate[] chain, String authType, |
|
864 |
Socket socket) throws CertificateException { |
|
865 |
tm.checkServerTrusted(chain, authType); |
|
866 |
checkAdditionalTrust(chain, authType, socket, false); |
|
867 |
} |
|
868 |
||
869 |
@Override |
|
870 |
public void checkClientTrusted(X509Certificate[] chain, String authType, |
|
871 |
SSLEngine engine) throws CertificateException { |
|
872 |
tm.checkClientTrusted(chain, authType); |
|
873 |
checkAdditionalTrust(chain, authType, engine, true); |
|
874 |
} |
|
875 |
||
876 |
@Override |
|
877 |
public void checkServerTrusted(X509Certificate[] chain, String authType, |
|
878 |
SSLEngine engine) throws CertificateException { |
|
879 |
tm.checkServerTrusted(chain, authType); |
|
880 |
checkAdditionalTrust(chain, authType, engine, false); |
|
881 |
} |
|
882 |
||
883 |
private void checkAdditionalTrust(X509Certificate[] chain, String authType, |
|
884 |
Socket socket, boolean isClient) throws CertificateException { |
|
885 |
if (socket != null && socket.isConnected() && |
|
886 |
socket instanceof SSLSocket) { |
|
887 |
||
888 |
SSLSocket sslSocket = (SSLSocket)socket; |
|
889 |
SSLSession session = sslSocket.getHandshakeSession(); |
|
890 |
if (session == null) { |
|
891 |
throw new CertificateException("No handshake session"); |
|
892 |
} |
|
893 |
||
894 |
// check endpoint identity |
|
895 |
String identityAlg = sslSocket.getSSLParameters(). |
|
896 |
getEndpointIdentificationAlgorithm(); |
|
897 |
if (identityAlg != null && identityAlg.length() != 0) { |
|
898 |
String hostname = session.getPeerHost(); |
|
899 |
X509TrustManagerImpl.checkIdentity( |
|
900 |
hostname, chain[0], identityAlg); |
|
901 |
} |
|
902 |
||
903 |
// try the best to check the algorithm constraints |
|
904 |
ProtocolVersion protocolVersion = |
|
905 |
ProtocolVersion.valueOf(session.getProtocol()); |
|
906 |
AlgorithmConstraints constraints = null; |
|
907 |
if (protocolVersion.v >= ProtocolVersion.TLS12.v) { |
|
908 |
if (session instanceof ExtendedSSLSession) { |
|
909 |
ExtendedSSLSession extSession = |
|
910 |
(ExtendedSSLSession)session; |
|
911 |
String[] peerSupportedSignAlgs = |
|
912 |
extSession.getLocalSupportedSignatureAlgorithms(); |
|
913 |
||
914 |
constraints = new SSLAlgorithmConstraints( |
|
915 |
sslSocket, peerSupportedSignAlgs, true); |
|
916 |
} else { |
|
917 |
constraints = |
|
918 |
new SSLAlgorithmConstraints(sslSocket, true); |
|
919 |
} |
|
920 |
} else { |
|
921 |
constraints = new SSLAlgorithmConstraints(sslSocket, true); |
|
922 |
} |
|
923 |
||
11037
03c29eb4afa0
7113275: compatibility issue with MD2 trust anchor and old X509TrustManager
xuelei
parents:
10125
diff
changeset
|
924 |
checkAlgorithmConstraints(chain, constraints); |
7043 | 925 |
} |
926 |
} |
|
927 |
||
928 |
private void checkAdditionalTrust(X509Certificate[] chain, String authType, |
|
929 |
SSLEngine engine, boolean isClient) throws CertificateException { |
|
930 |
if (engine != null) { |
|
931 |
SSLSession session = engine.getHandshakeSession(); |
|
932 |
if (session == null) { |
|
933 |
throw new CertificateException("No handshake session"); |
|
934 |
} |
|
935 |
||
936 |
// check endpoint identity |
|
937 |
String identityAlg = engine.getSSLParameters(). |
|
938 |
getEndpointIdentificationAlgorithm(); |
|
939 |
if (identityAlg != null && identityAlg.length() != 0) { |
|
940 |
String hostname = session.getPeerHost(); |
|
941 |
X509TrustManagerImpl.checkIdentity( |
|
942 |
hostname, chain[0], identityAlg); |
|
943 |
} |
|
944 |
||
945 |
// try the best to check the algorithm constraints |
|
946 |
ProtocolVersion protocolVersion = |
|
947 |
ProtocolVersion.valueOf(session.getProtocol()); |
|
948 |
AlgorithmConstraints constraints = null; |
|
949 |
if (protocolVersion.v >= ProtocolVersion.TLS12.v) { |
|
950 |
if (session instanceof ExtendedSSLSession) { |
|
951 |
ExtendedSSLSession extSession = |
|
952 |
(ExtendedSSLSession)session; |
|
953 |
String[] peerSupportedSignAlgs = |
|
954 |
extSession.getLocalSupportedSignatureAlgorithms(); |
|
955 |
||
956 |
constraints = new SSLAlgorithmConstraints( |
|
957 |
engine, peerSupportedSignAlgs, true); |
|
958 |
} else { |
|
959 |
constraints = |
|
960 |
new SSLAlgorithmConstraints(engine, true); |
|
961 |
} |
|
962 |
} else { |
|
963 |
constraints = new SSLAlgorithmConstraints(engine, true); |
|
964 |
} |
|
965 |
||
11037
03c29eb4afa0
7113275: compatibility issue with MD2 trust anchor and old X509TrustManager
xuelei
parents:
10125
diff
changeset
|
966 |
checkAlgorithmConstraints(chain, constraints); |
03c29eb4afa0
7113275: compatibility issue with MD2 trust anchor and old X509TrustManager
xuelei
parents:
10125
diff
changeset
|
967 |
} |
03c29eb4afa0
7113275: compatibility issue with MD2 trust anchor and old X509TrustManager
xuelei
parents:
10125
diff
changeset
|
968 |
} |
03c29eb4afa0
7113275: compatibility issue with MD2 trust anchor and old X509TrustManager
xuelei
parents:
10125
diff
changeset
|
969 |
|
03c29eb4afa0
7113275: compatibility issue with MD2 trust anchor and old X509TrustManager
xuelei
parents:
10125
diff
changeset
|
970 |
private void checkAlgorithmConstraints(X509Certificate[] chain, |
03c29eb4afa0
7113275: compatibility issue with MD2 trust anchor and old X509TrustManager
xuelei
parents:
10125
diff
changeset
|
971 |
AlgorithmConstraints constraints) throws CertificateException { |
03c29eb4afa0
7113275: compatibility issue with MD2 trust anchor and old X509TrustManager
xuelei
parents:
10125
diff
changeset
|
972 |
|
03c29eb4afa0
7113275: compatibility issue with MD2 trust anchor and old X509TrustManager
xuelei
parents:
10125
diff
changeset
|
973 |
try { |
03c29eb4afa0
7113275: compatibility issue with MD2 trust anchor and old X509TrustManager
xuelei
parents:
10125
diff
changeset
|
974 |
// 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
|
975 |
int checkedLength = chain.length - 1; |
12302
0c8557ba0b8f
7142172: Custom TrustManagers that return null for getAcceptedIssuers will NPE
wetmore
parents:
11037
diff
changeset
|
976 |
|
0c8557ba0b8f
7142172: Custom TrustManagers that return null for getAcceptedIssuers will NPE
wetmore
parents:
11037
diff
changeset
|
977 |
Collection<X509Certificate> trustedCerts = new HashSet<>(); |
0c8557ba0b8f
7142172: Custom TrustManagers that return null for getAcceptedIssuers will NPE
wetmore
parents:
11037
diff
changeset
|
978 |
X509Certificate[] certs = tm.getAcceptedIssuers(); |
0c8557ba0b8f
7142172: Custom TrustManagers that return null for getAcceptedIssuers will NPE
wetmore
parents:
11037
diff
changeset
|
979 |
if ((certs != null) && (certs.length > 0)){ |
0c8557ba0b8f
7142172: Custom TrustManagers that return null for getAcceptedIssuers will NPE
wetmore
parents:
11037
diff
changeset
|
980 |
Collections.addAll(trustedCerts, certs); |
0c8557ba0b8f
7142172: Custom TrustManagers that return null for getAcceptedIssuers will NPE
wetmore
parents:
11037
diff
changeset
|
981 |
} |
0c8557ba0b8f
7142172: Custom TrustManagers that return null for getAcceptedIssuers will NPE
wetmore
parents:
11037
diff
changeset
|
982 |
|
11037
03c29eb4afa0
7113275: compatibility issue with MD2 trust anchor and old X509TrustManager
xuelei
parents:
10125
diff
changeset
|
983 |
if (trustedCerts.contains(chain[checkedLength])) { |
03c29eb4afa0
7113275: compatibility issue with MD2 trust anchor and old X509TrustManager
xuelei
parents:
10125
diff
changeset
|
984 |
checkedLength--; |
03c29eb4afa0
7113275: compatibility issue with MD2 trust anchor and old X509TrustManager
xuelei
parents:
10125
diff
changeset
|
985 |
} |
03c29eb4afa0
7113275: compatibility issue with MD2 trust anchor and old X509TrustManager
xuelei
parents:
10125
diff
changeset
|
986 |
|
03c29eb4afa0
7113275: compatibility issue with MD2 trust anchor and old X509TrustManager
xuelei
parents:
10125
diff
changeset
|
987 |
// 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
|
988 |
if (checkedLength >= 0) { |
03c29eb4afa0
7113275: compatibility issue with MD2 trust anchor and old X509TrustManager
xuelei
parents:
10125
diff
changeset
|
989 |
AlgorithmChecker checker = new AlgorithmChecker(constraints); |
7043 | 990 |
checker.init(false); |
11037
03c29eb4afa0
7113275: compatibility issue with MD2 trust anchor and old X509TrustManager
xuelei
parents:
10125
diff
changeset
|
991 |
for (int i = checkedLength; i >= 0; i--) { |
7043 | 992 |
Certificate cert = chain[i]; |
993 |
// We don't care about the unresolved critical extensions. |
|
994 |
checker.check(cert, Collections.<String>emptySet()); |
|
995 |
} |
|
996 |
} |
|
11037
03c29eb4afa0
7113275: compatibility issue with MD2 trust anchor and old X509TrustManager
xuelei
parents:
10125
diff
changeset
|
997 |
} catch (CertPathValidatorException cpve) { |
03c29eb4afa0
7113275: compatibility issue with MD2 trust anchor and old X509TrustManager
xuelei
parents:
10125
diff
changeset
|
998 |
throw new CertificateException( |
03c29eb4afa0
7113275: compatibility issue with MD2 trust anchor and old X509TrustManager
xuelei
parents:
10125
diff
changeset
|
999 |
"Certificates does not conform to algorithm constraints"); |
7043 | 1000 |
} |
1001 |
} |
|
1002 |
} |
|
1003 |
||
2 | 1004 |
// Dummy X509TrustManager implementation, rejects all peer certificates. |
1005 |
// Used if the application did not specify a proper X509TrustManager. |
|
7043 | 1006 |
final class DummyX509TrustManager extends X509ExtendedTrustManager |
1007 |
implements X509TrustManager { |
|
2 | 1008 |
|
1009 |
static final X509TrustManager INSTANCE = new DummyX509TrustManager(); |
|
1010 |
||
1011 |
private DummyX509TrustManager() { |
|
1012 |
// empty |
|
1013 |
} |
|
1014 |
||
1015 |
/* |
|
1016 |
* Given the partial or complete certificate chain |
|
1017 |
* provided by the peer, build a certificate path |
|
1018 |
* to a trusted root and return if it can be |
|
1019 |
* validated and is trusted for client SSL authentication. |
|
1020 |
* If not, it throws an exception. |
|
1021 |
*/ |
|
7043 | 1022 |
@Override |
2 | 1023 |
public void checkClientTrusted(X509Certificate[] chain, String authType) |
1024 |
throws CertificateException { |
|
1025 |
throw new CertificateException( |
|
1026 |
"No X509TrustManager implementation avaiable"); |
|
1027 |
} |
|
1028 |
||
1029 |
/* |
|
1030 |
* Given the partial or complete certificate chain |
|
1031 |
* provided by the peer, build a certificate path |
|
1032 |
* to a trusted root and return if it can be |
|
1033 |
* validated and is trusted for server SSL authentication. |
|
1034 |
* If not, it throws an exception. |
|
1035 |
*/ |
|
7043 | 1036 |
@Override |
2 | 1037 |
public void checkServerTrusted(X509Certificate[] chain, String authType) |
1038 |
throws CertificateException { |
|
1039 |
throw new CertificateException( |
|
1040 |
"No X509TrustManager implementation available"); |
|
1041 |
} |
|
1042 |
||
1043 |
/* |
|
1044 |
* Return an array of issuer certificates which are trusted |
|
1045 |
* for authenticating peers. |
|
1046 |
*/ |
|
7043 | 1047 |
@Override |
2 | 1048 |
public X509Certificate[] getAcceptedIssuers() { |
1049 |
return new X509Certificate[0]; |
|
1050 |
} |
|
7043 | 1051 |
|
1052 |
@Override |
|
1053 |
public void checkClientTrusted(X509Certificate[] chain, String authType, |
|
1054 |
Socket socket) throws CertificateException { |
|
1055 |
throw new CertificateException( |
|
1056 |
"No X509TrustManager implementation available"); |
|
1057 |
} |
|
1058 |
||
1059 |
@Override |
|
1060 |
public void checkServerTrusted(X509Certificate[] chain, String authType, |
|
1061 |
Socket socket) throws CertificateException { |
|
1062 |
throw new CertificateException( |
|
1063 |
"No X509TrustManager implementation available"); |
|
1064 |
} |
|
1065 |
||
1066 |
@Override |
|
1067 |
public void checkClientTrusted(X509Certificate[] chain, String authType, |
|
1068 |
SSLEngine engine) throws CertificateException { |
|
1069 |
throw new CertificateException( |
|
1070 |
"No X509TrustManager implementation available"); |
|
1071 |
} |
|
1072 |
||
1073 |
@Override |
|
1074 |
public void checkServerTrusted(X509Certificate[] chain, String authType, |
|
1075 |
SSLEngine engine) throws CertificateException { |
|
1076 |
throw new CertificateException( |
|
1077 |
"No X509TrustManager implementation available"); |
|
1078 |
} |
|
2 | 1079 |
} |
1080 |
||
1081 |
/* |
|
1082 |
* A wrapper class to turn a X509KeyManager into an X509ExtendedKeyManager |
|
1083 |
*/ |
|
7043 | 1084 |
final class AbstractKeyManagerWrapper extends X509ExtendedKeyManager { |
2 | 1085 |
|
1086 |
private final X509KeyManager km; |
|
1087 |
||
7043 | 1088 |
AbstractKeyManagerWrapper(X509KeyManager km) { |
2 | 1089 |
this.km = km; |
1090 |
} |
|
1091 |
||
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
13815
diff
changeset
|
1092 |
@Override |
2 | 1093 |
public String[] getClientAliases(String keyType, Principal[] issuers) { |
1094 |
return km.getClientAliases(keyType, issuers); |
|
1095 |
} |
|
1096 |
||
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
13815
diff
changeset
|
1097 |
@Override |
2 | 1098 |
public String chooseClientAlias(String[] keyType, Principal[] issuers, |
1099 |
Socket socket) { |
|
1100 |
return km.chooseClientAlias(keyType, issuers, socket); |
|
1101 |
} |
|
1102 |
||
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
13815
diff
changeset
|
1103 |
@Override |
2 | 1104 |
public String[] getServerAliases(String keyType, Principal[] issuers) { |
1105 |
return km.getServerAliases(keyType, issuers); |
|
1106 |
} |
|
1107 |
||
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
13815
diff
changeset
|
1108 |
@Override |
2 | 1109 |
public String chooseServerAlias(String keyType, Principal[] issuers, |
1110 |
Socket socket) { |
|
1111 |
return km.chooseServerAlias(keyType, issuers, socket); |
|
1112 |
} |
|
1113 |
||
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
13815
diff
changeset
|
1114 |
@Override |
2 | 1115 |
public X509Certificate[] getCertificateChain(String alias) { |
1116 |
return km.getCertificateChain(alias); |
|
1117 |
} |
|
1118 |
||
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
13815
diff
changeset
|
1119 |
@Override |
2 | 1120 |
public PrivateKey getPrivateKey(String alias) { |
1121 |
return km.getPrivateKey(alias); |
|
1122 |
} |
|
1123 |
||
1124 |
// Inherit chooseEngineClientAlias() and chooseEngineServerAlias() from |
|
1125 |
// X509ExtendedKeymanager. It defines them to return null; |
|
1126 |
} |
|
1127 |
||
1128 |
||
1129 |
// Dummy X509KeyManager implementation, never returns any certificates/keys. |
|
1130 |
// Used if the application did not specify a proper X509TrustManager. |
|
1131 |
final class DummyX509KeyManager extends X509ExtendedKeyManager { |
|
1132 |
||
1133 |
static final X509ExtendedKeyManager INSTANCE = new DummyX509KeyManager(); |
|
1134 |
||
1135 |
private DummyX509KeyManager() { |
|
1136 |
// empty |
|
1137 |
} |
|
1138 |
||
1139 |
/* |
|
1140 |
* Get the matching aliases for authenticating the client side of a secure |
|
1141 |
* socket given the public key type and the list of |
|
1142 |
* certificate issuer authorities recognized by the peer (if any). |
|
1143 |
*/ |
|
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
13815
diff
changeset
|
1144 |
@Override |
2 | 1145 |
public String[] getClientAliases(String keyType, Principal[] issuers) { |
1146 |
return null; |
|
1147 |
} |
|
1148 |
||
1149 |
/* |
|
1150 |
* Choose an alias to authenticate the client side of a secure |
|
1151 |
* socket given the public key type and the list of |
|
1152 |
* certificate issuer authorities recognized by the peer (if any). |
|
1153 |
*/ |
|
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
13815
diff
changeset
|
1154 |
@Override |
2 | 1155 |
public String chooseClientAlias(String[] keyTypes, Principal[] issuers, |
1156 |
Socket socket) { |
|
1157 |
return null; |
|
1158 |
} |
|
1159 |
||
1160 |
/* |
|
1161 |
* Choose an alias to authenticate the client side of an |
|
1162 |
* engine given the public key type and the list of |
|
1163 |
* certificate issuer authorities recognized by the peer (if any). |
|
1164 |
*/ |
|
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
13815
diff
changeset
|
1165 |
@Override |
2 | 1166 |
public String chooseEngineClientAlias( |
1167 |
String[] keyTypes, Principal[] issuers, SSLEngine engine) { |
|
1168 |
return null; |
|
1169 |
} |
|
1170 |
||
1171 |
/* |
|
1172 |
* Get the matching aliases for authenticating the server side of a secure |
|
1173 |
* socket given the public key type and the list of |
|
1174 |
* certificate issuer authorities recognized by the peer (if any). |
|
1175 |
*/ |
|
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
13815
diff
changeset
|
1176 |
@Override |
2 | 1177 |
public String[] getServerAliases(String keyType, Principal[] issuers) { |
1178 |
return null; |
|
1179 |
} |
|
1180 |
||
1181 |
/* |
|
1182 |
* Choose an alias to authenticate the server side of a secure |
|
1183 |
* socket given the public key type and the list of |
|
1184 |
* certificate issuer authorities recognized by the peer (if any). |
|
1185 |
*/ |
|
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
13815
diff
changeset
|
1186 |
@Override |
2 | 1187 |
public String chooseServerAlias(String keyType, Principal[] issuers, |
1188 |
Socket socket) { |
|
1189 |
return null; |
|
1190 |
} |
|
1191 |
||
1192 |
/* |
|
1193 |
* Choose an alias to authenticate the server side of an engine |
|
1194 |
* given the public key type and the list of |
|
1195 |
* certificate issuer authorities recognized by the peer (if any). |
|
1196 |
*/ |
|
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
13815
diff
changeset
|
1197 |
@Override |
2 | 1198 |
public String chooseEngineServerAlias( |
1199 |
String keyType, Principal[] issuers, SSLEngine engine) { |
|
1200 |
return null; |
|
1201 |
} |
|
1202 |
||
1203 |
/** |
|
1204 |
* Returns the certificate chain associated with the given alias. |
|
1205 |
* |
|
1206 |
* @param alias the alias name |
|
1207 |
* |
|
1208 |
* @return the certificate chain (ordered with the user's certificate first |
|
1209 |
* and the root certificate authority last) |
|
1210 |
*/ |
|
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
13815
diff
changeset
|
1211 |
@Override |
2 | 1212 |
public X509Certificate[] getCertificateChain(String alias) { |
1213 |
return null; |
|
1214 |
} |
|
1215 |
||
1216 |
/* |
|
1217 |
* Returns the key associated with the given alias, using the given |
|
1218 |
* password to recover it. |
|
1219 |
* |
|
1220 |
* @param alias the alias name |
|
1221 |
* |
|
1222 |
* @return the requested key |
|
1223 |
*/ |
|
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
13815
diff
changeset
|
1224 |
@Override |
2 | 1225 |
public PrivateKey getPrivateKey(String alias) { |
1226 |
return null; |
|
1227 |
} |
|
1228 |
} |