@@ -804,21 +804,26 @@ private String getHighestCommonTlsVersion(Session sess) throws Exception {
804
804
805
805
/**
806
806
* Tests fix for Bug#25494338, ENABLEDSSLCIPHERSUITES PARAMETER NOT WORKING AS EXPECTED WITH X-PLUGIN.
807
+ *
808
+ * @throws Exception
807
809
*/
808
810
@ Test
809
- public void testBug25494338 () {
811
+ public void testBug25494338 () throws Exception {
810
812
assumeTrue (supportsTestCertificates (this .session ),
811
813
"This test requires the server configured with SSL certificates from ConnectorJ/src/test/config/ssl-test-certs" );
812
814
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.
822
827
}
823
828
824
829
Session testSession = null ;
@@ -838,7 +843,7 @@ public void testBug25494338() {
838
843
839
844
// 1. Allow only TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256/TLS_AES_256_GCM_SHA384 cipher
840
845
props .setProperty (PropertyKey .tlsCiphersuites .getKeyName (), testCipher1 );
841
- Session sess = this .fact .getSession (props );
846
+ sess = this .fact .getSession (props );
842
847
assertSessionStatusEquals (sess , "mysqlx_ssl_cipher" , expectedCipher1 );
843
848
sess .close ();
844
849
@@ -949,22 +954,18 @@ public void testXdevapiTlsVersionsAndCiphersuites() throws Exception {
949
954
"This test requires the server configured with SSL certificates from ConnectorJ/src/test/config/ssl-test-certs" );
950
955
assumeTrue (supportsTestCertificates (this .session ), "This test requires the server with RSA support." );
951
956
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.
955
961
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.
960
966
testCipher2 = "TLS_AES_128_GCM_SHA256" ;
961
967
}
962
968
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
-
968
969
Properties props = new Properties (this .sslFreeTestProperties );
969
970
props .setProperty (PropertyKey .xdevapiSslMode .getKeyName (), PropertyDefinitions .XdevapiSslMode .VERIFY_CA .toString ());
970
971
props .setProperty (PropertyKey .xdevapiSslTrustStoreUrl .getKeyName (), this .trustStoreUrl );
@@ -1189,7 +1190,7 @@ public void testXdevapiTlsVersionsAndCiphersuites() throws Exception {
1189
1190
// Assess that the session is created successfully and the connection properties are initialized with the expected values.
1190
1191
testSession = this .fact .getSession (this .sslFreeBaseUrl );
1191
1192
assertSecureSession (testSession );
1192
- assertTlsVersion (testSession , highestCommonTlsVersion );
1193
+ assertTlsVersion (testSession , testTlsVersion );
1193
1194
testSession .close ();
1194
1195
1195
1196
// 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 {
1216
1217
props .remove (PropertyKey .xdevapiTlsCiphersuites .getKeyName ());
1217
1218
testSession = this .fact .getSession (props );
1218
1219
assertSecureSession (testSession );
1219
- assertTlsVersion (testSession , highestCommonTlsVersion );
1220
+ assertTlsVersion (testSession , testTlsVersion );
1220
1221
testSession .close ();
1221
1222
1222
1223
// 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 {
1243
1244
cli = cf .getClient (this .sslFreeBaseUrl , "{\" pooling\" : {\" enabled\" : true}}" );
1244
1245
testSession = cli .getSession ();
1245
1246
assertSecureSession (testSession );
1246
- assertTlsVersion (testSession , highestCommonTlsVersion );
1247
+ assertTlsVersion (testSession , testTlsVersion );
1247
1248
cli .close ();
1248
1249
1249
1250
cli = cf .getClient (this .sslFreeBaseUrl + makeParam (PropertyKey .xdevapiTlsVersions , testTlsVersion ), "{\" pooling\" : {\" enabled\" : true}}" );
@@ -1734,16 +1735,16 @@ public void testTLSVersionRemoval() throws Exception {
1734
1735
assumeTrue (supportsTestCertificates (this .session ),
1735
1736
"This test requires the server configured with SSL certificates from ConnectorJ/src/test/config/ssl-test-certs" );
1736
1737
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.
1744
1746
}
1745
1747
1746
- Session sess = null ;
1747
1748
Properties props = new Properties (this .sslFreeTestProperties );
1748
1749
props .setProperty (PropertyKey .sslMode .getKeyName (), SslMode .REQUIRED .name ());
1749
1750
props .setProperty (PropertyKey .allowPublicKeyRetrieval .getKeyName (), "true" );
0 commit comments