@@ -50,15 +50,13 @@ describe.concurrent('ssl', function () {
5050 let serverCaFile = Conf . baseConfig . ssl && Conf . baseConfig . ssl . ca ? null : getEnv ( 'TEST_DB_SERVER_CERT' ) ;
5151 let clientKeyFileName = getEnv ( 'TEST_DB_CLIENT_KEY' ) ;
5252 let clientCertFileName = getEnv ( 'TEST_DB_CLIENT_CERT' ) ;
53- let clientKeystoreFileName = getEnv ( 'TEST_DB_CLIENT_PKCS' ) ;
5453
5554 if ( ! serverCaFile && ( Conf . baseConfig . host === 'localhost' || Conf . baseConfig . host === 'mariadb.example.com' ) ) {
5655 try {
5756 if ( fs . existsSync ( '../../ssl' ) ) {
58- serverCaFile = '../../ssl/server .crt' ;
57+ serverCaFile = '../../ssl/ca_server .crt' ;
5958 clientKeyFileName = '../../ssl/client.key' ;
6059 clientCertFileName = '../../ssl/client.crt' ;
61- clientKeystoreFileName = '../../ssl/fullclient-keystore.p12' ;
6260 }
6361 } catch ( err ) {
6462 console . error ( err ) ;
@@ -68,7 +66,6 @@ describe.concurrent('ssl', function () {
6866 if ( serverCaFile ) ca = [ fs . readFileSync ( serverCaFile , 'utf8' ) ] ;
6967 if ( clientKeyFileName ) clientKey = [ fs . readFileSync ( clientKeyFileName , 'utf8' ) ] ;
7068 if ( clientCertFileName ) clientCert = [ fs . readFileSync ( clientCertFileName , 'utf8' ) ] ;
71- if ( clientKeystoreFileName ) clientKeystore = [ fs . readFileSync ( clientKeystoreFileName ) ] ;
7269
7370 await shareConn . query ( "DROP USER IF EXISTS 'sslTestUser'" + getHostSuffix ( ) ) ;
7471 await shareConn . query ( "DROP USER IF EXISTS 'X509testUser'" + getHostSuffix ( ) ) ;
@@ -349,7 +346,7 @@ describe.concurrent('ssl', function () {
349346 ssl : { rejectUnauthorized : false , secureProtocol : 'TLSv1_method' } ,
350347 port : sslPort
351348 } ) ;
352- checkProtocol ( conn , 'TLSv1' ) ;
349+ await checkProtocol ( conn , 'TLSv1' ) ;
353350 await conn . end ( ) ;
354351 } ) ;
355352
@@ -370,7 +367,7 @@ describe.concurrent('ssl', function () {
370367 ssl : { rejectUnauthorized : false , secureProtocol : 'TLSv1_1_method' } ,
371368 port : sslPort
372369 } ) ;
373- checkProtocol ( conn , 'TLSv1.1' ) ;
370+ await checkProtocol ( conn , 'TLSv1.1' ) ;
374371 await conn . end ( ) ;
375372 } ) ;
376373
@@ -396,7 +393,7 @@ describe.concurrent('ssl', function () {
396393 } ,
397394 port : sslPort
398395 } ) ;
399- checkProtocol ( conn , 'TLSv1.1' ) ;
396+ await checkProtocol ( conn , 'TLSv1.1' ) ;
400397 await conn . end ( ) ;
401398 } ) ;
402399
@@ -467,7 +464,7 @@ describe.concurrent('ssl', function () {
467464 ssl : { rejectUnauthorized : false , secureProtocol : 'TLSv1_2_method' } ,
468465 port : sslPort
469466 } ) ;
470- checkProtocol ( conn , 'TLSv1.2' ) ;
467+ await checkProtocol ( conn , 'TLSv1.2' ) ;
471468 await conn . end ( ) ;
472469 } ) ;
473470
@@ -493,7 +490,7 @@ describe.concurrent('ssl', function () {
493490 } ,
494491 port : sslPort
495492 } ) ;
496- checkProtocol ( conn , 'TLSv1.2' ) ;
493+ await checkProtocol ( conn , 'TLSv1.2' ) ;
497494 await validConnection ( conn ) ;
498495 await conn . end ( ) ;
499496 } ) ;
@@ -543,15 +540,18 @@ describe.concurrent('ssl', function () {
543540 if ( Conf . baseConfig . host !== 'localhost' ) return skip ( ) ;
544541
545542 try {
546- await createConnection ( { host : '127.0.0.1' , ssl : { ca : ca } } ) ;
543+ await createConnection ( { ssl : { ca : ca } } ) ;
547544 throw new Error ( 'Must have thrown an exception !' ) ;
548545 } catch ( err ) {
549- assert (
550- err . message . includes ( "Hostname/IP doesn't match certificate's altnames" ) ||
551- err . message . includes ( "Hostname/IP does not match certificate's altnames" ) ,
552- 'error was : ' + err . message
553- ) ;
554- assert ( err . message . includes ( "IP: 127.0.0.1 is not in the cert's list" ) , 'error was : ' + err . message ) ;
546+ if ( isDeno ( ) ) {
547+ assert ( err . message . includes ( 'write UNKNOWN' ) , 'error was : ' + err . message ) ;
548+ } else {
549+ assert (
550+ err . message . includes ( "Hostname/IP doesn't match certificate's altnames" ) ||
551+ err . message . includes ( "Hostname/IP does not match certificate's altnames" ) ,
552+ 'error was : ' + err . message
553+ ) ;
554+ }
555555 }
556556 } ) ;
557557
@@ -571,7 +571,7 @@ describe.concurrent('ssl', function () {
571571 } else if ( ! shareConn . info . hasMinVersion ( 5 , 7 , 28 ) ) {
572572 expectedProtocol = 'TLSv1.1' ;
573573 }
574- checkProtocol ( conn , expectedProtocol ) ;
574+ await checkProtocol ( conn , expectedProtocol ) ;
575575 await validConnection ( conn ) ;
576576 await conn . end ( ) ;
577577 } ) ;
@@ -706,9 +706,12 @@ describe.concurrent('ssl', function () {
706706 } , 10000 ) ;
707707} ) ;
708708
709- function checkProtocol ( conn , protocol ) {
710- const currentProtocol = isDeno ( ) ? conn . __tests . getSocket ( ) . protocol : conn . __tests . getSocket ( ) . getProtocol ( ) ;
711-
709+ async function checkProtocol ( conn , protocol ) {
710+ let currentProtocol = isDeno ( ) ? conn . __tests . getSocket ( ) . protocol : conn . __tests . getSocket ( ) . getProtocol ( ) ;
711+ if ( ! currentProtocol ) {
712+ const res = await conn . query ( "SHOW STATUS LIKE 'Ssl_version'" ) ;
713+ currentProtocol = res [ 0 ] . Value ;
714+ }
712715 if ( Array . isArray ( protocol ) ) {
713716 for ( let i = 0 ; i < protocol . length ; i ++ ) {
714717 if ( currentProtocol === protocol [ i ] ) return ;
0 commit comments