diff --git a/src/crypto/crypto_common.cc b/src/crypto/crypto_common.cc index f318dcf6fa195d..f3497f8ee008a7 100644 --- a/src/crypto/crypto_common.cc +++ b/src/crypto/crypto_common.cc @@ -112,27 +112,12 @@ MaybeLocal GetSSLOCSPResponse( return ret; } -bool SetTLSSession( - const SSLPointer& ssl, - const unsigned char* buf, - size_t length) { - SSLSessionPointer s(d2i_SSL_SESSION(nullptr, &buf, length)); - return s == nullptr ? false : SetTLSSession(ssl, s); -} - bool SetTLSSession( const SSLPointer& ssl, const SSLSessionPointer& session) { return session != nullptr && SSL_set_session(ssl.get(), session.get()) == 1; } -SSLSessionPointer GetTLSSession(Local val) { - if (!val->IsArrayBufferView()) - return SSLSessionPointer(); - ArrayBufferViewContents sbuf(val.As()); - return GetTLSSession(sbuf.data(), sbuf.length()); -} - SSLSessionPointer GetTLSSession(const unsigned char* buf, size_t length) { return SSLSessionPointer(d2i_SSL_SESSION(nullptr, &buf, length)); } diff --git a/src/crypto/crypto_common.h b/src/crypto/crypto_common.h index 7cf72022230c8e..e0956395e91c18 100644 --- a/src/crypto/crypto_common.h +++ b/src/crypto/crypto_common.h @@ -42,17 +42,10 @@ v8::MaybeLocal GetSSLOCSPResponse( SSL* ssl, v8::Local default_value); -bool SetTLSSession( - const SSLPointer& ssl, - const unsigned char* buf, - size_t length); - bool SetTLSSession( const SSLPointer& ssl, const SSLSessionPointer& session); -SSLSessionPointer GetTLSSession(v8::Local val); - SSLSessionPointer GetTLSSession(const unsigned char* buf, size_t length); long VerifyPeerCertificate( // NOLINT(runtime/int) diff --git a/src/crypto/crypto_tls.cc b/src/crypto/crypto_tls.cc index cfe760adb3af1d..72b49e05f0cb0d 100644 --- a/src/crypto/crypto_tls.cc +++ b/src/crypto/crypto_tls.cc @@ -1667,10 +1667,10 @@ void TLSWrap::SetSession(const FunctionCallbackInfo& args) { return THROW_ERR_MISSING_ARGS(env, "Session argument is mandatory"); THROW_AND_RETURN_IF_NOT_BUFFER(env, args[0], "Session"); - - SSLSessionPointer sess = GetTLSSession(args[0]); + ArrayBufferViewContents sbuf(args[0]); + SSLSessionPointer sess = GetTLSSession(sbuf.data(), sbuf.length()); if (sess == nullptr) - return; + return; // TODO(tniessen): figure out error handling if (!SetTLSSession(w->ssl_, sess)) return env->ThrowError("SSL_set_session error");