From 6ca0270320095d5c700fbf59e844ce339162d50b Mon Sep 17 00:00:00 2001 From: Sam Roberts Date: Wed, 24 Apr 2019 10:44:01 -0700 Subject: [PATCH] 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: https://github.com/nodejs/node/pull/27390 Reviewed-By: Richard Lau Reviewed-By: Colin Ihrig Reviewed-By: Brian White Reviewed-By: James M Snell --- src/node_crypto.cc | 3 ++- test/parallel/test-tls-no-sslv23.js | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 49d1d417796daa..4529a5d22d0c19 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -627,7 +627,8 @@ void SecureContext::Init(const FunctionCallbackInfo& 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; } } diff --git a/test/parallel/test-tls-no-sslv23.js b/test/parallel/test-tls-no-sslv23.js index 737f42b530d93a..f1ba670ff07664 100644 --- a/test/parallel/test-tls-no-sslv23.js +++ b/test/parallel/test-tls-no-sslv23.js @@ -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/;