Skip to content

Commit 2df1963

Browse files
committed
[misc] zero config not permitting non plugins without hash
1 parent a752a1e commit 2df1963

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

lib/cmd/handshake/authentication.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: LGPL-2.1-or-later
2-
// Copyright (c) 2015-2024 MariaDB Corporation Ab
2+
// Copyright (c) 2015-2025 MariaDB Corporation Ab
33

44
'use strict';
55

@@ -81,7 +81,7 @@ class Authentication extends Command {
8181
if (packet.remaining()) {
8282
const validationHash = packet.readBufferLengthEncoded();
8383
if (validationHash.length > 0) {
84-
if (!this.plugin.permitHash() || !this.cmdParam.opts.password || this.cmdParam.opts.password === '') {
84+
if (!this.plugin.permitHash() || !Boolean(this.cmdParam.opts.password)) {
8585
return this.throwNewError(
8686
'Self signed certificates. Either set `ssl: { rejectUnauthorized: false }` (trust mode) or provide server certificate to client',
8787
true,
@@ -253,6 +253,21 @@ class Authentication extends Command {
253253
pluginData = packet.readBufferRemaining();
254254
}
255255

256+
if (
257+
info.requireValidCert &&
258+
info.selfSignedCertificate &&
259+
Boolean(this.cmdParam.opts.password) &&
260+
!this.plugin.permitHash()
261+
) {
262+
return this.throwNewError(
263+
`Unsupported authentication plugin ${pluginName} with Self signed certificates. Either set 'ssl: { rejectUnauthorized: false }' (trust mode) or provide server certificate to client`,
264+
true,
265+
info,
266+
'08000',
267+
Errors.ER_SELF_SIGNED_BAD_PLUGIN
268+
);
269+
}
270+
256271
if (opts.restrictedAuth && !opts.restrictedAuth.includes(pluginName)) {
257272
this.throwNewError(
258273
`Unsupported authentication plugin ${pluginName}. Authorized plugin: ${opts.restrictedAuth.toString()}`,

lib/misc/errors.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: LGPL-2.1-or-later
2-
// Copyright (c) 2015-2024 MariaDB Corporation Ab
2+
// Copyright (c) 2015-2025 MariaDB Corporation Ab
33

44
'use strict';
55
const ErrorCodes = require('../const/error-code');
@@ -152,6 +152,7 @@ module.exports.ER_PRIVATE_FIELDS_USE = 45058;
152152
module.exports.ER_TLS_IDENTITY_ERROR = 45059;
153153
module.exports.ER_POOL_NOT_INITIALIZED = 45060;
154154
module.exports.ER_POOL_NO_CONNECTION = 45061;
155+
module.exports.ER_SELF_SIGNED_BAD_PLUGIN = 45062;
155156

156157
const keys = Object.keys(module.exports);
157158
const errByNo = {};

0 commit comments

Comments
 (0)