[CONJS-323] correcting TypeError: validationFunction is not a function

This commit is contained in:
Diego Dupin
2025-07-11 15:52:08 +02:00
parent 4ba5a020a3
commit 0273e9af46
2 changed files with 23 additions and 2 deletions

View File

@ -99,7 +99,7 @@ class Authentication extends Command {
} else {
// certificate is not self signed, validate server identity
const validationFunction =
opts.ssl === true || opts.ssl.checkServerIdentity === null
opts.ssl === true || typeof opts.ssl.checkServerIdentity !== 'function'
? tls.checkServerIdentity
: opts.ssl.checkServerIdentity;
const identityError = validationFunction(

View File

@ -468,7 +468,7 @@ describe('ssl', function () {
if (!shareConn.info.isMariaDB() && !shareConn.info.hasMinVersion(5, 7, 10)) this.skip();
if (Conf.baseConfig.host !== 'localhost') this.skip();
const conn = await base.createConnection({
let conn = await base.createConnection({
ssl: {
ca: ca,
checkServerIdentity: (servername, cert) => {}
@ -477,6 +477,27 @@ describe('ssl', function () {
});
await validConnection(conn);
conn.end();
let success = false;
try {
conn = await base.createConnection({
ssl: {
ca: ca,
checkServerIdentity: (servername, cert) => {
throw new Error('test identity');
}
},
port: sslPort
});
await validConnection(conn);
conn.end();
success = true;
} catch (e) {
// eat
}
if (success && (!shareConn.info.isMariaDB() || !shareConn.info.hasMinVersion(11, 4, 0))) {
throw new Error('Must have thrown an exception, since server identity must not have been verified !');
}
});
it('CA name verification error', async function () {