|
8 | 8 | #include <async_wrap-inl.h> |
9 | 9 | #include <base_object-inl.h> |
10 | 10 | #include <crypto/crypto_x509.h> |
| 11 | +#include <crypto/crypto_common.h> |
11 | 12 | #include <env-inl.h> |
12 | 13 | #include <memory_tracker-inl.h> |
13 | 14 | #include <node_buffer.h> |
@@ -1037,31 +1038,8 @@ void DTLSSession::GetCipher(const FunctionCallbackInfo<Value>& args) { |
1037 | 1038 | ASSIGN_OR_RETURN_UNWRAP(&session, args.This()); |
1038 | 1039 | Environment* env = session->env(); |
1039 | 1040 |
|
1040 | | - const SSL_CIPHER* cipher = SSL_get_current_cipher(session->ssl_.get()); |
1041 | | - if (cipher == nullptr) return; |
1042 | | - |
1043 | | - // Build the three strings up front so a failure leaves the return value |
1044 | | - // untouched rather than a half-populated object. |
1045 | | - Local<Value> name; |
1046 | | - Local<Value> standard_name; |
1047 | | - Local<Value> version; |
1048 | | - if (!ToV8Value(env->context(), SSL_CIPHER_get_name(cipher)).ToLocal(&name) || |
1049 | | - !ToV8Value(env->context(), SSL_CIPHER_standard_name(cipher)) |
1050 | | - .ToLocal(&standard_name) || |
1051 | | - !ToV8Value(env->context(), SSL_CIPHER_get_version(cipher)) |
1052 | | - .ToLocal(&version)) { |
1053 | | - return; |
1054 | | - } |
1055 | | - |
1056 | | - Local<Object> info = Object::New(env->isolate()); |
1057 | | - info->Set(env->context(), env->name_string(), name).Check(); |
1058 | | - info->Set(env->context(), |
1059 | | - FIXED_ONE_BYTE_STRING(env->isolate(), "standardName"), |
1060 | | - standard_name) |
1061 | | - .Check(); |
1062 | | - info->Set(env->context(), env->version_string(), version).Check(); |
1063 | | - |
1064 | | - args.GetReturnValue().Set(info); |
| 1041 | + args.GetReturnValue().Set( |
| 1042 | + crypto::GetCipherInfo(env, session->ssl_).FromMaybe(Local<Object>())); |
1065 | 1043 | } |
1066 | 1044 |
|
1067 | 1045 | void DTLSSession::GetPeerCertificate(const FunctionCallbackInfo<Value>& args) { |
|
0 commit comments