summaryrefslogtreecommitdiff
path: root/src/node_crypto.cc
diff options
context:
space:
mode:
authorSam Roberts <vieuxtech@gmail.com>2018-11-26 12:25:59 -0800
committerSam Roberts <vieuxtech@gmail.com>2019-01-22 13:34:01 -0800
commit3f419e897ba3b1a412dd300649282ee14d5df361 (patch)
tree651fc1030834e3db45ff3e56d5794d5400b5ecd7 /src/node_crypto.cc
parent807ed7883a12423270450776f015a7c2348c0913 (diff)
downloadandroid-node-v8-3f419e897ba3b1a412dd300649282ee14d5df361.tar.gz
android-node-v8-3f419e897ba3b1a412dd300649282ee14d5df361.tar.bz2
android-node-v8-3f419e897ba3b1a412dd300649282ee14d5df361.zip
tls: make ossl 1.1.1 cipher list throw error
Make OpenSSL 1.1.1 error during cipher list setting if it would have errored with OpenSSL 1.1.0. Can be dropped after our OpenSSL fixes this upstream. See: https://github.com/openssl/openssl/pull/7759 PR-URL: https://github.com/nodejs/node/pull/25381 Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Shigeki Ohtsu <ohtsu@ohtsu.org>
Diffstat (limited to 'src/node_crypto.cc')
-rw-r--r--src/node_crypto.cc20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/node_crypto.cc b/src/node_crypto.cc
index 3ff9548487..01593914a1 100644
--- a/src/node_crypto.cc
+++ b/src/node_crypto.cc
@@ -946,8 +946,26 @@ void SecureContext::SetCiphers(const FunctionCallbackInfo<Value>& args) {
THROW_AND_RETURN_IF_NOT_STRING(env, args[0], "Ciphers");
+ // Note: set_ciphersuites() is for TLSv1.3 and was introduced in openssl
+ // 1.1.1, set_cipher_list() is for TLSv1.2 and earlier.
+ //
+ // In openssl 1.1.0, set_cipher_list() would error if it resulted in no
+ // TLSv1.2 (and earlier) cipher suites, and there is no TLSv1.3 support.
+ //
+ // In openssl 1.1.1, set_cipher_list() will not error if it results in no
+ // TLSv1.2 cipher suites if there are any TLSv1.3 cipher suites, which there
+ // are by default. There will be an error later, during the handshake, but
+ // that results in an async error event, rather than a sync error thrown,
+ // which is a semver-major change for the tls API.
+ //
+ // Since we don't currently support TLSv1.3, work around this by removing the
+ // TLSv1.3 cipher suites, so we get backwards compatible synchronous errors.
const node::Utf8Value ciphers(args.GetIsolate(), args[0]);
- if (!SSL_CTX_set_cipher_list(sc->ctx_.get(), *ciphers)) {
+ if (
+#ifdef TLS1_3_VERSION
+ !SSL_CTX_set_ciphersuites(sc->ctx_.get(), "") ||
+#endif
+ !SSL_CTX_set_cipher_list(sc->ctx_.get(), *ciphers)) {
unsigned long err = ERR_get_error(); // NOLINT(runtime/int)
if (!err) {
return env->ThrowError("Failed to set ciphers");