mirror of
https://github.com/nodejs/node.git
synced 2026-11-29 14:27:57 -05:00
src: reuse crypto GetCipherInfo in DTLS session
Signed-off-by: ishabi <ilyasshabi94@gmail.com> PR-URL: https://github.com/nodejs/node/pull/66022 Reviewed-By: Xuguang Mei <meixuguang@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
1 parent
aa531a34f7
commit
b98787fe2d
1 file changed
+3
-25
@@ -7,6 +7,7 @@
|
||||
#include <aliased_struct-inl.h>
|
||||
#include <async_wrap-inl.h>
|
||||
#include <base_object-inl.h>
|
||||
#include <crypto/crypto_common.h>
|
||||
#include <crypto/crypto_x509.h>
|
||||
#include <env-inl.h>
|
||||
#include <memory_tracker-inl.h>
|
||||
@@ -1034,31 +1035,8 @@ void DTLSSession::GetCipher(const FunctionCallbackInfo<Value>& 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<Value> name;
|
||||
Local<Value> standard_name;
|
||||
Local<Value> 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<Object> 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<Object>()));
|
||||
}
|
||||
|
||||
void DTLSSession::GetPeerCertificate(const FunctionCallbackInfo<Value>& args) {
|
||||
|
||||
Reference in new issue
Block a user