-
Notifications
You must be signed in to change notification settings - Fork 101
Description
I was debugging the driver to resolve an SNI issue (trying to pass servername as an SSL option) and discovered what I think is an issue in the createSecureContext method:
mariadb-connector-nodejs/lib/connection.js
Line 1337 in d8fc60a
createSecureContext(info, callback) { |
If you supply a checkServerIdentity function in the ssl config, then it wont be called, and no SSL identity check will be performed, due to this line:
info.requireIdentifyCheck = this.opts.ssl === true || this.opts.ssl.checkServerIdentity === undefined;
I think the last check should be !== undefined, since if it's defined then it should be used and an identity check performed.
However, that causes another issue in this line:
const sslOption = this.opts.ssl === true ? baseConf : Object.assign({}, this.opts.ssl, baseConf);
baseConf is applied over the supplied ssl options, rather than the other way around. This leads to the no op function in baseConf being used, and since it does not return (same as returning undefined) the check still passes.
If both of those are fixed, then this line in handshakeResult
const identityError = tls.checkServerIdentity(opts.host, info.tlsCert);
should probably change to something like:
const identityError = tls.checkServerIdentity(typeof opts.ssl === 'object' && opts.ssl.servername ? opts.ssl.servername : opts.host, info.tlsCert);
I can put all this in a PR if that's preferred ? Just wanted to confirm this is right, or am I missing something.