From b98787fe2d8b7037352b0989ce6389c2fdb62bca Mon Sep 17 00:00:00 2001 From: Ilyas Shabi Date: Fri, 18 Sep 2026 12:17:30 +0200 Subject: [PATCH] src: reuse crypto GetCipherInfo in DTLS session Signed-off-by: ishabi PR-URL: https://github.com/nodejs/node/pull/66022 Reviewed-By: Xuguang Mei Reviewed-By: James M Snell --- src/dtls/dtls_session.cc | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/src/dtls/dtls_session.cc b/src/dtls/dtls_session.cc index 2652f28d475..a410b5f6e2a 100644 --- a/src/dtls/dtls_session.cc +++ b/src/dtls/dtls_session.cc @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -1034,31 +1035,8 @@ void DTLSSession::GetCipher(const FunctionCallbackInfo& args) { ASSIGN_OR_RETURN_UNWRAP(&session, args.This()); Environment* env = session->env(); - const SSL_CIPHER* cipher = SSL_get_current_cipher(session->ssl_.get()); - if (cipher == nullptr) return; - - // Build the three strings up front so a failure leaves the return value - // untouched rather than a half-populated object. - Local name; - Local standard_name; - Local version; - if (!ToV8Value(env->context(), SSL_CIPHER_get_name(cipher)).ToLocal(&name) || - !ToV8Value(env->context(), SSL_CIPHER_standard_name(cipher)) - .ToLocal(&standard_name) || - !ToV8Value(env->context(), SSL_CIPHER_get_version(cipher)) - .ToLocal(&version)) { - return; - } - - Local info = Object::New(env->isolate()); - info->Set(env->context(), env->name_string(), name).Check(); - info->Set(env->context(), - FIXED_ONE_BYTE_STRING(env->isolate(), "standardName"), - standard_name) - .Check(); - info->Set(env->context(), env->version_string(), version).Check(); - - args.GetReturnValue().Set(info); + args.GetReturnValue().Set( + crypto::GetCipherInfo(env, session->ssl_).FromMaybe(Local())); } void DTLSSession::GetPeerCertificate(const FunctionCallbackInfo& args) {