Skip to content

Commit

Permalink
tls: include invalid method name in thrown error
Browse files Browse the repository at this point in the history
When an invalid TLS method name error is thrown, include the invalid
name in the error message.

PR-URL: #27390
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Brian White <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
sam-github authored and targos committed Apr 27, 2019
1 parent ae2333d commit 6ca0270
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/node_crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,8 @@ void SecureContext::Init(const FunctionCallbackInfo<Value>& args) {
max_version = TLS1_2_VERSION;
method = TLS_client_method();
} else {
THROW_ERR_TLS_INVALID_PROTOCOL_METHOD(env, "Unknown method");
const std::string msg("Unknown method: ");
THROW_ERR_TLS_INVALID_PROTOCOL_METHOD(env, (msg + * sslmethod).c_str());
return;
}
}
Expand Down
5 changes: 4 additions & 1 deletion test/parallel/test-tls-no-sslv23.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ const tls = require('tls');

assert.throws(function() {
tls.createSecureContext({ secureProtocol: 'blargh' });
}, /Unknown method/);
}, {
code: 'ERR_TLS_INVALID_PROTOCOL_METHOD',
message: 'Unknown method: blargh',
});

const errMessageSSLv2 = /SSLv2 methods disabled/;

Expand Down

0 comments on commit 6ca0270

Please sign in to comment.