@@ -804,21 +804,26 @@ private String getHighestCommonTlsVersion(Session sess) throws Exception {
804804
805805 /**
806806 * Tests fix for Bug#25494338, ENABLEDSSLCIPHERSUITES PARAMETER NOT WORKING AS EXPECTED WITH X-PLUGIN.
807+ *
808+ * @throws Exception
807809 */
808810 @ Test
809- public void testBug25494338 () {
811+ public void testBug25494338 () throws Exception {
810812 assumeTrue (supportsTestCertificates (this .session ),
811813 "This test requires the server configured with SSL certificates from ConnectorJ/src/test/config/ssl-test-certs" );
812814
813- String testCipher1 = "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" ; // IANA Cipher name
814- String expectedCipher1 = "ECDHE-RSA-AES128-GCM-SHA256" ; // OpenSSL Cipher name
815- String testCipher2 = "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384" ; // IANA Cipher name
816- String expectedCipher2 = "ECDHE-RSA-AES256-GCM-SHA384" ; // OpenSSL Cipher name
817- if (mysqlVersionMeetsMinimum (ServerVersion .parseVersion ("8.2.0" ))) {
818- testCipher1 = "TLS_AES_256_GCM_SHA384" ; // IANA Cipher name
819- expectedCipher1 = "TLS_AES_256_GCM_SHA384" ; // IANA Cipher name
820- testCipher2 = "TLS_AES_128_GCM_SHA256" ; // IANA Cipher name
821- expectedCipher2 = "TLS_AES_128_GCM_SHA256" ; // IANA Cipher name
815+ String testCipher1 = "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" ; // TLSv1.2 IANA Cipher name.
816+ String expectedCipher1 = "ECDHE-RSA-AES128-GCM-SHA256" ; // TLSv1.2 OpenSSL Cipher name.
817+ String testCipher2 = "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384" ; // TLSv1.2 IANA Cipher name.
818+ String expectedCipher2 = "ECDHE-RSA-AES256-GCM-SHA384" ; // TLSv1.2 OpenSSL Cipher name.
819+ Session sess = this .fact .getSession (this .baseUrl );
820+ String testTlsVersion = getHighestCommonTlsVersion (sess ); // At least TLSv1.2 is expected to be supported.
821+ sess .close ();
822+ if ("TLSv1.3" .equalsIgnoreCase (testTlsVersion )) {
823+ testCipher1 = "TLS_AES_256_GCM_SHA384" ; // TLSv1.3 IANA Cipher name.
824+ expectedCipher1 = "TLS_AES_256_GCM_SHA384" ; // TLSv1.3 IANA Cipher name.
825+ testCipher2 = "TLS_AES_128_GCM_SHA256" ; // TLSv1.3 IANA Cipher name.
826+ expectedCipher2 = "TLS_AES_128_GCM_SHA256" ; // TLSv1.3 IANA Cipher name.
822827 }
823828
824829 Session testSession = null ;
@@ -838,7 +843,7 @@ public void testBug25494338() {
838843
839844 // 1. Allow only TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256/TLS_AES_256_GCM_SHA384 cipher
840845 props .setProperty (PropertyKey .tlsCiphersuites .getKeyName (), testCipher1 );
841- Session sess = this .fact .getSession (props );
846+ sess = this .fact .getSession (props );
842847 assertSessionStatusEquals (sess , "mysqlx_ssl_cipher" , expectedCipher1 );
843848 sess .close ();
844849
@@ -949,22 +954,18 @@ public void testXdevapiTlsVersionsAndCiphersuites() throws Exception {
949954 "This test requires the server configured with SSL certificates from ConnectorJ/src/test/config/ssl-test-certs" );
950955 assumeTrue (supportsTestCertificates (this .session ), "This test requires the server with RSA support." );
951956
952- String testCipher = "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" ; // IANA Cipher name
953- String expectedCipher = "ECDHE-RSA-AES128-GCM-SHA256" ; // OpenSSL Cipher name
954- String testTlsVersion = "TLSv1.2" ;
957+ String testCipher = "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" ; // TLSv1.2 IANA Cipher name.
958+ String expectedCipher = "ECDHE-RSA-AES128-GCM-SHA256" ; // TLSv1.2 OpenSSL Cipher name.
959+ Session sess = this .fact .getSession (this .baseUrl );
960+ String testTlsVersion = getHighestCommonTlsVersion (sess ); // At least TLSv1.2 is expected to be supported.
955961 String testCipher2 = "DHE-RSA-AES128-GCM-SHA256" ;
956- if ( mysqlVersionMeetsMinimum ( ServerVersion . parseVersion ( "8.2.0" ))) {
957- testCipher = "TLS_AES_256_GCM_SHA384" ; // IANA Cipher name
958- expectedCipher = "TLS_AES_256_GCM_SHA384" ; // IANA Cipher name
959- testTlsVersion = "TLSv1.3" ;
962+ sess . close ();
963+ if ( "TLSv1.3" . equalsIgnoreCase ( testTlsVersion )) {
964+ testCipher = "TLS_AES_256_GCM_SHA384" ; // TLSv1.3 IANA Cipher name.
965+ expectedCipher = "TLS_AES_256_GCM_SHA384" ; // TLSv1.3 IANA Cipher name.
960966 testCipher2 = "TLS_AES_128_GCM_SHA256" ;
961967 }
962968
963- // newer GPL servers, like 8.0.4+, are using OpenSSL and can use RSA encryption, while old ones compiled with yaSSL cannot
964- Session sess = this .fact .getSession (this .sslFreeBaseUrl );
965- String highestCommonTlsVersion = getHighestCommonTlsVersion (sess );
966- sess .close ();
967-
968969 Properties props = new Properties (this .sslFreeTestProperties );
969970 props .setProperty (PropertyKey .xdevapiSslMode .getKeyName (), PropertyDefinitions .XdevapiSslMode .VERIFY_CA .toString ());
970971 props .setProperty (PropertyKey .xdevapiSslTrustStoreUrl .getKeyName (), this .trustStoreUrl );
@@ -1189,7 +1190,7 @@ public void testXdevapiTlsVersionsAndCiphersuites() throws Exception {
11891190 // Assess that the session is created successfully and the connection properties are initialized with the expected values.
11901191 testSession = this .fact .getSession (this .sslFreeBaseUrl );
11911192 assertSecureSession (testSession );
1192- assertTlsVersion (testSession , highestCommonTlsVersion );
1193+ assertTlsVersion (testSession , testTlsVersion );
11931194 testSession .close ();
11941195
11951196 // TS.FR.5_2. Create an X DevAPI session using a connection string with the connection property xdevapi.tls-versions but without
@@ -1216,7 +1217,7 @@ public void testXdevapiTlsVersionsAndCiphersuites() throws Exception {
12161217 props .remove (PropertyKey .xdevapiTlsCiphersuites .getKeyName ());
12171218 testSession = this .fact .getSession (props );
12181219 assertSecureSession (testSession );
1219- assertTlsVersion (testSession , highestCommonTlsVersion );
1220+ assertTlsVersion (testSession , testTlsVersion );
12201221 testSession .close ();
12211222
12221223 // TS.FR.5_5. Create an X DevAPI session using a connection properties map with the connection property xdevapi.tls-versions but without
@@ -1243,7 +1244,7 @@ public void testXdevapiTlsVersionsAndCiphersuites() throws Exception {
12431244 cli = cf .getClient (this .sslFreeBaseUrl , "{\" pooling\" : {\" enabled\" : true}}" );
12441245 testSession = cli .getSession ();
12451246 assertSecureSession (testSession );
1246- assertTlsVersion (testSession , highestCommonTlsVersion );
1247+ assertTlsVersion (testSession , testTlsVersion );
12471248 cli .close ();
12481249
12491250 cli = cf .getClient (this .sslFreeBaseUrl + makeParam (PropertyKey .xdevapiTlsVersions , testTlsVersion ), "{\" pooling\" : {\" enabled\" : true}}" );
@@ -1734,16 +1735,16 @@ public void testTLSVersionRemoval() throws Exception {
17341735 assumeTrue (supportsTestCertificates (this .session ),
17351736 "This test requires the server configured with SSL certificates from ConnectorJ/src/test/config/ssl-test-certs" );
17361737
1737- String testCipher = "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" ; // IANA Cipher name
1738- String expectedCipher = "ECDHE-RSA-AES128-GCM-SHA256" ; // OpenSSL Cipher name
1739- String testTlsVersion = "TLSv1.2" ;
1740- if (mysqlVersionMeetsMinimum (ServerVersion .parseVersion ("8.2.0" ))) {
1741- testCipher = "TLS_AES_256_GCM_SHA384" ; // IANA Cipher name
1742- expectedCipher = "TLS_AES_256_GCM_SHA384" ; // IANA Cipher name
1743- testTlsVersion = "TLSv1.3" ;
1738+ String testCipher = "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" ; // TLSv1.2 IANA Cipher name.
1739+ String expectedCipher = "ECDHE-RSA-AES128-GCM-SHA256" ; // TLSv1.2 OpenSSL Cipher name.
1740+ Session sess = this .fact .getSession (this .baseUrl );
1741+ String testTlsVersion = getHighestCommonTlsVersion (sess ); // At least TLSv1.2 is expected to be supported.
1742+ sess .close ();
1743+ if ("TLSv1.3" .equalsIgnoreCase (testTlsVersion )) {
1744+ testCipher = "TLS_AES_256_GCM_SHA384" ; // TLSv1.3 IANA Cipher name.
1745+ expectedCipher = "TLS_AES_256_GCM_SHA384" ; // TLSv1.3 IANA Cipher name.
17441746 }
17451747
1746- Session sess = null ;
17471748 Properties props = new Properties (this .sslFreeTestProperties );
17481749 props .setProperty (PropertyKey .sslMode .getKeyName (), SslMode .REQUIRED .name ());
17491750 props .setProperty (PropertyKey .allowPublicKeyRetrieval .getKeyName (), "true" );
0 commit comments