Skip to content

Commit 65368e4

Browse files
committed
Rename this._tls to this.secureConnection and fold into options
Allow insecure cleartext if options.insecureAuth == true
1 parent 6a785ae commit 65368e4

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

lib/protocol/Auth.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ var Buffer = require('safe-buffer').Buffer;
22
var Crypto = require('crypto');
33
var Auth = exports;
44

5-
function auth(name, data, options, isSecure) {
5+
function auth(name, data, options) {
66
options = options || {};
77

88
switch (name) {
99
case 'mysql_native_password':
1010
return Auth.token(options.password, data.slice(0, 20));
1111
case 'mysql_clear_password':
12-
if (!isSecure) {
12+
if (!options.secureConnection && !options.insecureAuth) {
1313
throw new Error('Authentication method mysql_clear_password not supported on insecure connections');
1414
} else {
1515
return Buffer.from(options.password);

lib/protocol/sequences/Handshake.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ Handshake.prototype['AuthSwitchRequestPacket'] = function (packet) {
3838
var data, error;
3939
try {
4040
data = Auth.auth(name, packet.authMethodData, {
41-
password: this._config.password
42-
}, this._tls);
41+
password : this._config.password,
42+
insecureAuth : this._config.insecureAuth,
43+
secureConnection : this._secureConnection
44+
});
4345
} catch (e) {
4446
error = e;
4547
}
@@ -87,7 +89,7 @@ Handshake.prototype['HandshakeInitializationPacket'] = function(packet) {
8789
};
8890

8991
Handshake.prototype._tlsUpgradeCompleteHandler = function() {
90-
this._tls = true;
92+
this._secureConnection = true;
9193
this._sendCredentials();
9294
};
9395

0 commit comments

Comments
 (0)