@@ -115,6 +115,10 @@ public final class X509Util {
115115 "hbase.client.netty.tls.handshaketimeout" ;
116116 public static final int DEFAULT_HANDSHAKE_DETECTION_TIMEOUT_MILLIS = 5000 ;
117117
118+ private static String [] getTls13Ciphers () {
119+ return new String [] { "TLS_AES_128_GCM_SHA256" , "TLS_AES_256_GCM_SHA384" };
120+ }
121+
118122 private static String [] getGCMCiphers () {
119123 return new String [] { "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256" ,
120124 "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" , "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384" ,
@@ -136,14 +140,17 @@ private static String[] getCBCCiphers() {
136140 // Note that this performance assumption might not hold true for architectures other than x86_64.
137141 private static final String [] DEFAULT_CIPHERS_JAVA9 =
138142 ObjectArrays .concat (getGCMCiphers (), getCBCCiphers (), String .class );
143+ private static final String [] DEFAULT_CIPHERS_JAVA11 =
144+ ObjectArrays .concat (ObjectArrays .concat (getTls13Ciphers (), getGCMCiphers (), String .class ),
145+ getCBCCiphers (), String .class );
139146
140147 private static final String [] DEFAULT_CIPHERS_OPENSSL = getOpenSslFilteredDefaultCiphers ();
141148
142149 /**
143150 * Not all of our default ciphers are available in OpenSSL. Takes our default cipher lists and
144- * filters them to only those available in OpenSsl. Does GCM first , then CBC because GCM tends to
145- * be better and faster, and we don't need to worry about the java8 vs 9 performance issue if
146- * OpenSSL is handling it.
151+ * filters them to only those available in OpenSsl. Prefers TLS 1.3 , then GCM, then CBC because
152+ * GCM tends to be better and faster, and we don't need to worry about the java8 vs 9 performance
153+ * issue if OpenSSL is handling it.
147154 */
148155 private static String [] getOpenSslFilteredDefaultCiphers () {
149156 if (!OpenSsl .isAvailable ()) {
@@ -152,16 +159,9 @@ private static String[] getOpenSslFilteredDefaultCiphers() {
152159
153160 Set <String > openSslSuites = OpenSsl .availableJavaCipherSuites ();
154161 List <String > defaultSuites = new ArrayList <>();
155- for (String cipher : getGCMCiphers ()) {
156- if (openSslSuites .contains (cipher )) {
157- defaultSuites .add (cipher );
158- }
159- }
160- for (String cipher : getCBCCiphers ()) {
161- if (openSslSuites .contains (cipher )) {
162- defaultSuites .add (cipher );
163- }
164- }
162+ Arrays .stream (getTls13Ciphers ()).filter (openSslSuites ::contains ).forEach (defaultSuites ::add );
163+ Arrays .stream (getGCMCiphers ()).filter (openSslSuites ::contains ).forEach (defaultSuites ::add );
164+ Arrays .stream (getCBCCiphers ()).filter (openSslSuites ::contains ).forEach (defaultSuites ::add );
165165 return defaultSuites .toArray (new String [0 ]);
166166 }
167167
@@ -219,10 +219,19 @@ static String[] getDefaultCipherSuites(boolean useOpenSsl) {
219219
220220 static String [] getDefaultCipherSuitesForJavaVersion (String javaVersion ) {
221221 Objects .requireNonNull (javaVersion );
222+
222223 if (javaVersion .matches ("\\ d+" )) {
223224 // Must be Java 9 or later
224- LOG .debug ("Using Java9+ optimized cipher suites for Java version {}" , javaVersion );
225- return DEFAULT_CIPHERS_JAVA9 ;
225+ int javaVersionInt = Integer .parseInt (javaVersion );
226+ if (javaVersionInt >= 11 ) {
227+ LOG .debug (
228+ "Using Java11+ optimized cipher suites for Java version {}, including TLSv1.3 support" ,
229+ javaVersion );
230+ return DEFAULT_CIPHERS_JAVA11 ;
231+ } else {
232+ LOG .debug ("Using Java9+ optimized cipher suites for Java version {}" , javaVersion );
233+ return DEFAULT_CIPHERS_JAVA9 ;
234+ }
226235 } else if (javaVersion .startsWith ("1." )) {
227236 // Must be Java 1.8 or earlier
228237 LOG .debug ("Using Java8 optimized cipher suites for Java version {}" , javaVersion );
0 commit comments