|
27 | 27 | import java.io.IOException;
|
28 | 28 | import java.nio.ByteBuffer;
|
29 | 29 | import java.nio.file.Files;
|
| 30 | +import java.security.Security; |
30 | 31 | import java.util.ArrayList;
|
31 | 32 | import java.util.Arrays;
|
32 | 33 | import java.util.Collections;
|
@@ -197,6 +198,41 @@ public void run() {
|
197 | 198 | // Creation
|
198 | 199 | // =========================================================================
|
199 | 200 |
|
| 201 | + /** |
| 202 | + * Ensure that anonymous cipher suites are enabled in the JRE. |
| 203 | + */ |
| 204 | + static { |
| 205 | + final String property = "jdk.tls.disabledAlgorithms"; |
| 206 | + final String value = Security.getProperty(property); |
| 207 | + if (!(value == null || value.trim().isEmpty())) { |
| 208 | + final List<String> algorithms = new ArrayList<>(); |
| 209 | + boolean isChanged = false; |
| 210 | + for (String algorithm : value.split(",")) { |
| 211 | + algorithm = algorithm.trim(); |
| 212 | + if (algorithm.isEmpty()) { |
| 213 | + /* ignore */ |
| 214 | + } else if ("anon".equals(algorithm.toLowerCase())) { |
| 215 | + isChanged = true; |
| 216 | + } else { |
| 217 | + algorithms.add(algorithm); |
| 218 | + } |
| 219 | + } |
| 220 | + if (isChanged) { |
| 221 | + boolean needsComma = false; |
| 222 | + final StringBuilder newValue = new StringBuilder(); |
| 223 | + for (final String algorithm : algorithms) { |
| 224 | + if (needsComma) { |
| 225 | + newValue.append(", "); |
| 226 | + } else { |
| 227 | + needsComma = true; |
| 228 | + } |
| 229 | + newValue.append(algorithm); |
| 230 | + } |
| 231 | + Security.setProperty(property, newValue.toString()); |
| 232 | + } |
| 233 | + } |
| 234 | + } |
| 235 | + |
200 | 236 | private static Properties defaultRouter(String host, int port) {
|
201 | 237 | Properties p = new Properties();
|
202 | 238 | p.setProperty("omero.host", host);
|
|
0 commit comments