tsaarni commented on code in PR #1919: URL: https://github.com/apache/zookeeper/pull/1919#discussion_r1336257400
########## zookeeper-server/src/main/java/org/apache/zookeeper/common/X509Util.java: ########## @@ -81,7 +87,32 @@ public abstract class X509Util implements Closeable, AutoCloseable { } } - public static final String DEFAULT_PROTOCOL = "TLSv1.2"; + public static final String DEFAULT_PROTOCOL = defaultTlsProtocol(); + + /** + * Return TLSv1.3 or TLSv1.2 depending on Java runtime version being used. + * TLSv1.3 was first introduced in JDK11 and back-ported to OpenJDK 8u272. + */ + private static String defaultTlsProtocol() { + String defaultProtocol = "TLSv1.2"; + List<String> supported = new ArrayList<>(); + try { + supported = Arrays.asList(SSLContext.getDefault().getSupportedSSLParameters().getProtocols()); + if (supported.contains("TLSv1.3")) { + defaultProtocol = "TLSv1.3"; + } + } catch (NoSuchAlgorithmException e) { + // Ignore. + } + LOG.info("Default TLS protocol is {}, supported TLS protocols are {}", defaultProtocol, supported); + return defaultProtocol; + } + + // ChaCha20 was introduced in OpenJDK 11.0.15 and it is not supported by JDK8. + private static String[] getTLSv13Ciphers() { + return new String[]{"TLS_AES_256_GCM_SHA384", "TLS_AES_128_GCM_SHA256", "TLS_CHACHA20_POLY1305_SHA256"}; + } Review Comment: Exactly, this whole problem of TLSv1.3 not working _began_ from hardcoded ciphers in ZK, https://issues.apache.org/jira/browse/ZOOKEEPER-4415?focusedCommentId=17497994&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-17497994 but did not dare to change that - so in a way building on top what existed. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@zookeeper.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org