@@ -84,9 +84,13 @@ private static void createSslUser(String user, String requirement) throws SQLExc
8484
8585 private String getSslVersion (Connection con ) throws SQLException {
8686 Statement stmt = con .createStatement ();
87- ResultSet rs = stmt .executeQuery ("show STATUS LIKE 'Ssl_version'" );
88- if (rs .next ()) {
89- return rs .getString (2 );
87+ if ("maxscale" .equals (System .getenv ("srv" )) || "skysql-ha" .equals (System .getenv ("srv" ))) {
88+ return "ok" ;
89+ } else {
90+ ResultSet rs = stmt .executeQuery ("show STATUS LIKE 'Ssl_version'" );
91+ if (rs .next ()) {
92+ return rs .getString (2 );
93+ }
9094 }
9195 return null ;
9296 }
@@ -163,6 +167,29 @@ public void enabledSslCipherSuites() throws SQLException {
163167 "Unsupported SSL cipher" );
164168 }
165169
170+ @ Test
171+ public void errorUsingWrongTypeOfKeystore () throws Exception {
172+ Assumptions .assumeTrue (
173+ !"maxscale" .equals (System .getenv ("srv" )) && !"skysql-ha" .equals (System .getenv ("srv" )));
174+ String pkcsFile = System .getenv ("TEST_DB_CLIENT_PKCS" );
175+ Assumptions .assumeTrue (pkcsFile != null );
176+
177+ if (checkFileExists (pkcsFile ) != null ) {
178+ // wrong keystore type
179+ assertThrows (
180+ SQLNonTransientConnectionException .class ,
181+ () ->
182+ createCon (
183+ baseMutualOptions
184+ + "&sslMode=verify-ca&serverSslCert="
185+ + pkcsFile
186+ + "&trustStoreType=JKS&keyStore="
187+ + System .getenv ("TEST_DB_CLIENT_PKCS" )
188+ + "&keyStorePassword=kspass" ,
189+ sslPort ));
190+ }
191+ }
192+
166193 @ Test
167194 public void mutualAuthSsl () throws Exception {
168195 Assumptions .assumeTrue (
@@ -189,21 +216,6 @@ public void mutualAuthSsl() throws Exception {
189216 assertNotNull (getSslVersion (con ));
190217 }
191218
192- String pkcsFile = System .getenv ("TEST_DB_CLIENT_PKCS" );
193- if (pkcsFile != null && checkFileExists (pkcsFile ) != null ) {
194- // wrong keystore type
195- assertThrows (
196- SQLNonTransientConnectionException .class ,
197- () ->
198- createCon (
199- baseMutualOptions
200- + "&sslMode=verify-ca&serverSslCert="
201- + pkcsFile
202- + "&trustStoreType=JKS&keyStore="
203- + System .getenv ("TEST_DB_CLIENT_PKCS" )
204- + "&keyStorePassword=kspass" ,
205- sslPort ));
206- }
207219 // with URL
208220 boolean isWin = System .getProperty ("os.name" ).toLowerCase (Locale .ROOT ).contains ("win" );
209221 try (Connection con =
@@ -323,15 +335,17 @@ public void certificateMandatorySsl() throws Throwable {
323335 createCon (baseOptions + "&sslMode=VERIFY_CA&serverSslCert=" + certificateString , sslPort )) {
324336 assertNotNull (getSslVersion (con ));
325337 }
326-
327- assertThrows (
338+ assertThrowsContains (
328339 SQLNonTransientConnectionException .class ,
329- () -> createCon (baseOptions + "&sslMode=VERIFY_CA" , sslPort ));
330- assertThrows (
331- SQLInvalidAuthorizationSpecException .class ,
332- () ->
333- createCon (
334- baseMutualOptions + "&sslMode=VERIFY_CA&serverSslCert=" + serverCertPath , sslPort ));
340+ () -> createBasicCon (baseOptions + "&sslMode=VERIFY_CA" , sslPort ),
341+ "unable to find valid certification" );
342+ if (!"maxscale" .equals (System .getenv ("srv" ))) {
343+ assertThrows (
344+ SQLInvalidAuthorizationSpecException .class ,
345+ () ->
346+ createBasicCon (
347+ baseMutualOptions + "&sslMode=VERIFY_CA&serverSslCert=" + serverCertPath , sslPort ));
348+ }
335349 }
336350
337351 private String getServerCertificate (String serverCertPath ) throws SQLException {
0 commit comments