Skip to content

Commit 6ca0270

Browse files
sam-githubtargos
authored andcommitted
tls: include invalid method name in thrown error
When an invalid TLS method name error is thrown, include the invalid name in the error message. PR-URL: #27390 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent ae2333d commit 6ca0270

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/node_crypto.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,8 @@ void SecureContext::Init(const FunctionCallbackInfo<Value>& args) {
627627
max_version = TLS1_2_VERSION;
628628
method = TLS_client_method();
629629
} else {
630-
THROW_ERR_TLS_INVALID_PROTOCOL_METHOD(env, "Unknown method");
630+
const std::string msg("Unknown method: ");
631+
THROW_ERR_TLS_INVALID_PROTOCOL_METHOD(env, (msg + * sslmethod).c_str());
631632
return;
632633
}
633634
}

test/parallel/test-tls-no-sslv23.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ const tls = require('tls');
88

99
assert.throws(function() {
1010
tls.createSecureContext({ secureProtocol: 'blargh' });
11-
}, /Unknown method/);
11+
}, {
12+
code: 'ERR_TLS_INVALID_PROTOCOL_METHOD',
13+
message: 'Unknown method: blargh',
14+
});
1215

1316
const errMessageSSLv2 = /SSLv2 methods disabled/;
1417

0 commit comments

Comments
 (0)