Lines 485-490
void SecureContext::Init(const FunctionCallbackInfo<Value>& args) {
Link Here
|
485 |
SSL_SESS_CACHE_NO_AUTO_CLEAR); |
485 |
SSL_SESS_CACHE_NO_AUTO_CLEAR); |
486 |
|
486 |
|
487 |
SSL_CTX_set_min_proto_version(sc->ctx_.get(), min_version); |
487 |
SSL_CTX_set_min_proto_version(sc->ctx_.get(), min_version); |
|
|
488 |
|
489 |
if (max_version == 0) { |
490 |
// Selecting some secureProtocol methods allows the TLS version to be "any |
491 |
// supported", but we don't support TLSv1.3, even if OpenSSL does. |
492 |
max_version = TLS1_2_VERSION; |
493 |
} |
488 |
SSL_CTX_set_max_proto_version(sc->ctx_.get(), max_version); |
494 |
SSL_CTX_set_max_proto_version(sc->ctx_.get(), max_version); |
489 |
// OpenSSL 1.1.0 changed the ticket key size, but the OpenSSL 1.0.x size was |
495 |
// OpenSSL 1.1.0 changed the ticket key size, but the OpenSSL 1.0.x size was |
490 |
// exposed in the public API. To retain compatibility, install a callback |
496 |
// exposed in the public API. To retain compatibility, install a callback |
Lines 906-913
void SecureContext::SetCiphers(const FunctionCallbackInfo<Value>& args) {
Link Here
|
906 |
|
912 |
|
907 |
THROW_AND_RETURN_IF_NOT_STRING(env, args[0], "Ciphers"); |
913 |
THROW_AND_RETURN_IF_NOT_STRING(env, args[0], "Ciphers"); |
908 |
|
914 |
|
|
|
915 |
// Note: set_ciphersuites() is for TLSv1.3 and was introduced in openssl |
916 |
// 1.1.1, set_cipher_list() is for TLSv1.2 and earlier. |
917 |
// |
918 |
// In openssl 1.1.0, set_cipher_list() would error if it resulted in no |
919 |
// TLSv1.2 (and earlier) cipher suites, and there is no TLSv1.3 support. |
920 |
// |
921 |
// In openssl 1.1.1, set_cipher_list() will not error if it results in no |
922 |
// TLSv1.2 cipher suites if there are any TLSv1.3 cipher suites, which there |
923 |
// are by default. There will be an error later, during the handshake, but |
924 |
// that results in an async error event, rather than a sync error thrown, |
925 |
// which is a semver-major change for the tls API. |
926 |
// |
927 |
// Since we don't currently support TLSv1.3, work around this by removing the |
928 |
// TLSv1.3 cipher suites, so we get backwards compatible synchronous errors. |
909 |
const node::Utf8Value ciphers(args.GetIsolate(), args[0]); |
929 |
const node::Utf8Value ciphers(args.GetIsolate(), args[0]); |
910 |
if (!SSL_CTX_set_cipher_list(sc->ctx_.get(), *ciphers)) { |
930 |
if ( |
|
|
931 |
#ifdef TLS1_3_VERSION |
932 |
!SSL_CTX_set_ciphersuites(sc->ctx_.get(), "") || |
933 |
#endif |
934 |
!SSL_CTX_set_cipher_list(sc->ctx_.get(), *ciphers)) { |
911 |
unsigned long err = ERR_get_error(); // NOLINT(runtime/int) |
935 |
unsigned long err = ERR_get_error(); // NOLINT(runtime/int) |
912 |
if (!err) { |
936 |
if (!err) { |
913 |
return env->ThrowError("Failed to set ciphers"); |
937 |
return env->ThrowError("Failed to set ciphers"); |