From eabf3e4baa70bb3b4c98284c99a6a5fcb1d147aa Mon Sep 17 00:00:00 2001 From: Sam Roberts Date: Sun, 6 May 2018 13:52:34 +0900 Subject: [PATCH] tls: add min/max protocol version options The existing secureProtocol option only allows setting the allowed protocol to a specific version, or setting it to "all supported versions". It also used obscure strings based on OpenSSL C API functions. Directly setting the min or max is easier to use and explain. Backport-PR-URL: https://github.com/nodejs/node/pull/24676 PR-URL: https://github.com/nodejs/node/pull/24405 Reviewed-By: Refael Ackermann Reviewed-By: Rod Vagg --- doc/api/errors.md | 11 ++ doc/api/tls.md | 21 ++- lib/_tls_common.js | 40 ++++-- lib/_tls_wrap.js | 14 ++ lib/https.js | 8 ++ lib/internal/errors.js | 4 + lib/tls.js | 4 + src/node_constants.cc | 4 + src/node_crypto.cc | 13 +- test/fixtures/tls-connect.js | 69 ++++++---- test/parallel/test-https-agent-getname.js | 4 +- test/parallel/test-tls-min-max-version.js | 149 ++++++++++++++++++++++ 12 files changed, 298 insertions(+), 43 deletions(-) create mode 100644 test/parallel/test-tls-min-max-version.js diff --git a/doc/api/errors.md b/doc/api/errors.md index 68bc1e1c5a4158..75d0f368ca7c2d 100644 --- a/doc/api/errors.md +++ b/doc/api/errors.md @@ -1655,6 +1655,17 @@ recommended to use 2048 bits or larger for stronger security. A TLS/SSL handshake timed out. In this case, the server must also abort the connection. + +### ERR_TLS_INVALID_PROTOCOL_VERSION + +Valid TLS protocol versions are `'TLSv1'`, `'TLSv1.1'`, or `'TLSv1.2'`. + + +### ERR_TLS_PROTOCOL_VERSION_CONFLICT + +Attempting to set a TLS protocol `minVersion` or `maxVersion` conflicts with an +attempt to set the `secureProtocol` explicitly. Use one mechanism or the other. + ### ERR_TLS_RENEGOTIATE diff --git a/doc/api/tls.md b/doc/api/tls.md index eeda97b74ee412..888b0eeb5a8ace 100644 --- a/doc/api/tls.md +++ b/doc/api/tls.md @@ -1054,6 +1054,10 @@ argument.