11import { expect } from 'chai' ;
2- import { execSync } from 'child_process' ;
3- import * as crypto from 'crypto' ;
2+ import * as fs from 'fs' ;
43import * as net from 'net' ;
4+ import * as path from 'path' ;
55import * as process from 'process' ;
66import * as sinon from 'sinon' ;
77import * as tls from 'tls' ;
@@ -459,24 +459,26 @@ describe('Connect Tests', function () {
459459 // TLS sockets created by tls.connect() do not honor keepAlive/noDelay constructor
460460 // options due to a Node.js bug (options are not forwarded to the net.Socket constructor).
461461 // The driver must call setKeepAlive/setNoDelay explicitly on all sockets.
462- // See: https://github.com/nodejs/node/issues/...
462+ // See: https://github.com/nodejs/node/issues/62003
463463
464464 let tlsServer : tls . Server ;
465465 let tlsPort : number ;
466466 let setKeepAliveSpy : sinon . SinonSpy ;
467467 let setNoDelaySpy : sinon . SinonSpy ;
468468
469+ const serverPem = fs . readFileSync (
470+ path . join ( __dirname , '../../integration/auth/ssl/server.pem' )
471+ ) ;
472+
469473 before ( function ( done ) {
470- const { privateKey } = crypto . generateKeyPairSync ( 'rsa' , { modulusLength : 2048 } ) ;
471- const key = privateKey . export ( { type : 'pkcs8' , format : 'pem' } ) ;
472- const cert = execSync (
473- 'openssl req -new -x509 -key /dev/stdin -out /dev/stdout -days 1 -subj /CN=localhost -batch 2>/dev/null' ,
474- { input : key }
475- ) . toString ( ) ;
476-
477- tlsServer = tls . createServer ( { key, cert } , ( ) => {
478- /* empty */
479- } ) ;
474+ // @SECLEVEL =0 allows the legacy test certificate (signed with SHA-1/1024-bit RSA)
475+ // to be accepted by OpenSSL 3.x, which rejects at the default security level.
476+ tlsServer = tls . createServer (
477+ { key : serverPem , cert : serverPem , ciphers : 'DEFAULT:@SECLEVEL=0' } ,
478+ ( ) => {
479+ /* empty */
480+ }
481+ ) ;
480482 tlsServer . listen ( 0 , '127.0.0.1' , ( ) => {
481483 tlsPort = ( tlsServer . address ( ) as net . AddressInfo ) . port ;
482484 done ( ) ;
@@ -501,7 +503,8 @@ describe('Connect Tests', function () {
501503 const socket = await makeSocket ( {
502504 hostAddress : new HostAddress ( `127.0.0.1:${ tlsPort } ` ) ,
503505 tls : true ,
504- rejectUnauthorized : false
506+ rejectUnauthorized : false ,
507+ ciphers : 'DEFAULT:@SECLEVEL=0'
505508 } as ConnectionOptions ) ;
506509
507510 try {
@@ -516,6 +519,7 @@ describe('Connect Tests', function () {
516519 hostAddress : new HostAddress ( `127.0.0.1:${ tlsPort } ` ) ,
517520 tls : true ,
518521 rejectUnauthorized : false ,
522+ ciphers : 'DEFAULT:@SECLEVEL=0' ,
519523 keepAliveInitialDelay : 5000
520524 } as ConnectionOptions ) ;
521525
@@ -530,7 +534,8 @@ describe('Connect Tests', function () {
530534 const socket = await makeSocket ( {
531535 hostAddress : new HostAddress ( `127.0.0.1:${ tlsPort } ` ) ,
532536 tls : true ,
533- rejectUnauthorized : false
537+ rejectUnauthorized : false ,
538+ ciphers : 'DEFAULT:@SECLEVEL=0'
534539 } as ConnectionOptions ) ;
535540
536541 try {
0 commit comments