31
31
* @bug 6668231
32
32
* @summary Presence of a critical subjectAltName causes JSSE's SunX509 to
33
33
* fail trusted checks
34
+ * @library /test/lib
34
35
* @run main/othervm CriticalSubjectAltName
35
36
* @author Xuelei Fan
36
37
*/
53
54
import java .security .Security ;
54
55
import java .security .cert .Certificate ;
55
56
57
+ import jdk .test .lib .Utils ;
58
+
56
59
public class CriticalSubjectAltName implements HostnameVerifier {
57
60
/*
58
61
* =============================================================
@@ -159,10 +162,12 @@ void doClientSide() throws Exception {
159
162
160
163
public static void main (String [] args ) throws Exception {
161
164
// MD5 is used in this test case, don't disable MD5 algorithm.
162
- Security .setProperty ("jdk.certpath.disabledAlgorithms" ,
163
- "MD2, RSA keySize < 1024" );
164
- Security .setProperty ("jdk.tls.disabledAlgorithms" ,
165
- "SSLv3, RC4, DH keySize < 768" );
165
+ if (!(Utils .isFIPS ())) {
166
+ Security .setProperty ("jdk.certpath.disabledAlgorithms" ,
167
+ "MD2, RSA keySize < 1024" );
168
+ Security .setProperty ("jdk.tls.disabledAlgorithms" ,
169
+ "SSLv3, RC4, DH keySize < 768" );
170
+ }
166
171
167
172
String keyFilename =
168
173
System .getProperty ("test.src" , "./" ) + "/" + pathToStores +
@@ -171,6 +176,11 @@ public static void main(String[] args) throws Exception {
171
176
System .getProperty ("test.src" , "./" ) + "/" + pathToStores +
172
177
"/" + trustStoreFile ;
173
178
179
+ if (Utils .isFIPS ()) {
180
+ keyFilename = Utils .revertJKSToPKCS12 (keyFilename , passwd );
181
+ trustFilename = Utils .revertJKSToPKCS12 (trustFilename , passwd );
182
+ }
183
+
174
184
System .setProperty ("javax.net.ssl.keyStore" , keyFilename );
175
185
System .setProperty ("javax.net.ssl.keyStorePassword" , passwd );
176
186
System .setProperty ("javax.net.ssl.trustStore" , trustFilename );
@@ -182,7 +192,29 @@ public static void main(String[] args) throws Exception {
182
192
/*
183
193
* Start the tests.
184
194
*/
185
- new CriticalSubjectAltName ();
195
+ try {
196
+ new CriticalSubjectAltName ();
197
+ } catch (Exception e ) {
198
+ if (Utils .isFIPS ()) {
199
+ if (e instanceof java .security .cert .CertPathValidatorException ) {
200
+ if ("Algorithm constraints check failed on signature algorithm: MD5withRSA" .equals (e .getMessage ())) {
201
+ System .out .println ("MD5withRSA is not a supported signature algorithm." );
202
+ return ;
203
+ } else {
204
+ System .out .println ("Unexpected exception msg: <" + e .getMessage () + "> is caught" );
205
+ return ;
206
+ }
207
+ } else {
208
+ System .out .println ("Unexpected exception is caught" );
209
+ e .printStackTrace ();
210
+ return ;
211
+ }
212
+ } else {
213
+ System .out .println ("Unexpected exception is caught in Non-FIPS mode" );
214
+ e .printStackTrace ();
215
+ return ;
216
+ }
217
+ }
186
218
}
187
219
188
220
Thread clientThread = null ;
0 commit comments