|
37 | 37 | import java.security.NoSuchAlgorithmException; |
38 | 38 | import java.util.Arrays; |
39 | 39 | import java.util.List; |
| 40 | +import java.util.Set; |
| 41 | +import java.util.TreeSet; |
40 | 42 | import java.util.concurrent.Callable; |
41 | 43 | import java.util.concurrent.CountDownLatch; |
42 | 44 | import java.util.concurrent.ExecutionException; |
@@ -823,27 +825,33 @@ public void testCreateSSLContext_hostnameVerificationNoCustomTrustStore(X509KeyT |
823 | 825 |
|
824 | 826 | @ParameterizedTest |
825 | 827 | @MethodSource("data") |
826 | | - public void testCreateSSLContext_ChaCha20Cipher(X509KeyType caKeyType, |
| 828 | + public void testCreateSSLContext_AllClientCiphers(X509KeyType caKeyType, |
827 | 829 | X509KeyType certKeyType, String keyPassword, Integer paramIndex) throws Exception { |
828 | 830 | init(caKeyType, certKeyType, keyPassword, paramIndex); |
829 | 831 |
|
830 | | - // TLS_CHACHA20_POLY1305_SHA256 cipher is a mandatory cipher suite on TLSv1.3, |
831 | | - // so a client with default configuration must support it. |
| 832 | + // Netty has an own list of supported ciphers, which is a subset of |
| 833 | + // JVM's available cipher suites. A client ssl engine must support every |
| 834 | + // cipher which is supported by the JVM. |
832 | 835 |
|
833 | | - ZKConfig zkConfig = new ZKConfig(); |
834 | | - zkConfig.setProperty(x509Util.getSslEnabledProtocolsProperty(), "TLSv1.3"); |
| 836 | + SSLContext defaultContext = SSLContext.getInstance("TLSv1.3"); |
| 837 | + defaultContext.init(null, null, null); |
| 838 | + |
| 839 | + String[] defaultCipherArray = defaultContext.getSupportedSSLParameters().getCipherSuites(); |
| 840 | + Set<String> defaultCipherSet = new TreeSet<>(Arrays.asList(defaultCipherArray)); |
835 | 841 |
|
836 | 842 | try (ClientX509Util clientX509Util = new ClientX509Util()) { |
837 | | - SslContext context = clientX509Util.createNettySslContextForClient(zkConfig); |
| 843 | + ZKConfig config = new ZKConfig(); |
| 844 | + config.setProperty(x509Util.getSslEnabledProtocolsProperty(), "TLSv1.3"); |
| 845 | + |
| 846 | + SslContext clientContext = clientX509Util.createNettySslContextForClient(config); |
838 | 847 |
|
839 | 848 | UnpooledByteBufAllocator byteBufAllocator = new UnpooledByteBufAllocator(false); |
840 | | - SSLEngine engine = context.newEngine(byteBufAllocator); |
| 849 | + SSLEngine engine = clientContext.newEngine(byteBufAllocator); |
841 | 850 |
|
842 | | - String[] enabledProtocols = engine.getEnabledProtocols(); |
843 | | - assertArrayEquals(new String[] { "TLSv1.3" }, enabledProtocols); |
| 851 | + String[] clientCipherArray = engine.getEnabledCipherSuites(); |
| 852 | + Set<String> clientCipherSet = new TreeSet<>(Arrays.asList(clientCipherArray)); |
844 | 853 |
|
845 | | - List<String> enabledCipherSuites = Arrays.asList(engine.getEnabledCipherSuites()); |
846 | | - assertTrue(enabledCipherSuites.contains("TLS_CHACHA20_POLY1305_SHA256")); |
| 854 | + assertEquals(defaultCipherSet, clientCipherSet); |
847 | 855 | } |
848 | 856 | } |
849 | 857 |
|
|
0 commit comments