Skip to content

Commit b0526ba

Browse files
davidbengibfahn
authored andcommitted
crypto: clear some SSL_METHOD deprecation warnings
Fixing the rest will be rather involved. I think the cleanest option is to deprecate the method string APIs which are weird to begin with. PR-URL: #16130 Backport-PR-URL: #18622 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Rod Vagg <[email protected]>
1 parent 7873826 commit b0526ba

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/node_crypto.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,8 @@ static int DH_set0_key(DH* dh, BIGNUM* pub_key, BIGNUM* priv_key) {
186186
return 1;
187187
}
188188

189+
static const SSL_METHOD* TLS_method() { return SSLv23_method(); }
190+
189191
static void SSL_SESSION_get0_ticket(const SSL_SESSION* s,
190192
const unsigned char** tick, size_t* len) {
191193
*len = s->tlsext_ticklen;
@@ -547,12 +549,12 @@ void SecureContext::Init(const FunctionCallbackInfo<Value>& args) {
547549
ASSIGN_OR_RETURN_UNWRAP(&sc, args.Holder());
548550
Environment* env = sc->env();
549551

550-
const SSL_METHOD* method = SSLv23_method();
552+
const SSL_METHOD* method = TLS_method();
551553

552554
if (args.Length() == 1 && args[0]->IsString()) {
553555
const node::Utf8Value sslmethod(env->isolate(), args[0]);
554556

555-
// Note that SSLv2 and SSLv3 are disallowed but SSLv2_method and friends
557+
// Note that SSLv2 and SSLv3 are disallowed but SSLv23_method and friends
556558
// are still accepted. They are OpenSSL's way of saying that all known
557559
// protocols are supported unless explicitly disabled (which we do below
558560
// for SSLv2 and SSLv3.)
@@ -600,7 +602,7 @@ void SecureContext::Init(const FunctionCallbackInfo<Value>& args) {
600602
sc->ctx_ = SSL_CTX_new(method);
601603
SSL_CTX_set_app_data(sc->ctx_, sc);
602604

603-
// Disable SSLv2 in the case when method == SSLv23_method() and the
605+
// Disable SSLv2 in the case when method == TLS_method() and the
604606
// cipher list contains SSLv2 ciphers (not the default, should be rare.)
605607
// The bundled OpenSSL doesn't have SSLv2 support but the system OpenSSL may.
606608
// SSLv3 is disabled because it's susceptible to downgrade attacks (POODLE.)
@@ -5947,7 +5949,7 @@ void RandomBytesBuffer(const FunctionCallbackInfo<Value>& args) {
59475949
void GetSSLCiphers(const FunctionCallbackInfo<Value>& args) {
59485950
Environment* env = Environment::GetCurrent(args);
59495951

5950-
SSL_CTX* ctx = SSL_CTX_new(TLSv1_server_method());
5952+
SSL_CTX* ctx = SSL_CTX_new(TLS_method());
59515953
if (ctx == nullptr) {
59525954
return env->ThrowError("SSL_CTX_new() failed.");
59535955
}

0 commit comments

Comments
 (0)