equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
129 |
129 |
130 try { |
130 try { |
131 sslIS.read(); |
131 sslIS.read(); |
132 sslOS.write('A'); |
132 sslOS.write('A'); |
133 sslOS.flush(); |
133 sslOS.flush(); |
134 } catch (SSLHandshakeException e) { |
134 } catch (SSLException ssle) { |
135 if (expectFail && !e.toString().contains("certificate_unknown")) { |
135 if (!expectFail) { |
136 throw new RuntimeException( |
136 throw ssle; |
137 "Expected to see certificate_unknown in exception output", |
137 } // Otherwise, ignore. |
138 e); |
|
139 } |
|
140 } |
138 } |
141 } |
139 } |
142 |
140 |
143 @Override |
141 @Override |
144 protected SSLContext createClientSSLContext() throws Exception { |
142 protected SSLContext createClientSSLContext() throws Exception { |
156 try { |
154 try { |
157 sslOS.write('B'); |
155 sslOS.write('B'); |
158 sslOS.flush(); |
156 sslOS.flush(); |
159 sslIS.read(); |
157 sslIS.read(); |
160 } catch (SSLHandshakeException e) { |
158 } catch (SSLHandshakeException e) { |
|
159 if (expectFail) { |
161 // focus on the CertPathValidatorException |
160 // focus on the CertPathValidatorException |
162 Throwable t = e.getCause().getCause(); |
161 Throwable t = e.getCause().getCause(); |
163 if ((t == null) |
162 if (t == null || !t.toString().contains("MD5withRSA")) { |
164 || (expectFail && !t.toString().contains("MD5withRSA"))) { |
163 throw new RuntimeException( |
165 throw new RuntimeException( |
|
166 "Expected to see MD5withRSA in exception output", t); |
164 "Expected to see MD5withRSA in exception output", t); |
|
165 } |
|
166 } else { |
|
167 throw e; |
167 } |
168 } |
168 } |
169 } |
169 } |
170 } |
170 |
171 |
171 /* |
172 /* |