Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: simplify TLSWrap::SetSession #42087

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 0 additions & 15 deletions src/crypto/crypto_common.cc
Expand Up @@ -116,27 +116,12 @@ MaybeLocal<Value> 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<Value> val) {
if (!val->IsArrayBufferView())
return SSLSessionPointer();
ArrayBufferViewContents<unsigned char> sbuf(val.As<ArrayBufferView>());
return GetTLSSession(sbuf.data(), sbuf.length());
}

SSLSessionPointer GetTLSSession(const unsigned char* buf, size_t length) {
return SSLSessionPointer(d2i_SSL_SESSION(nullptr, &buf, length));
}
Expand Down
7 changes: 0 additions & 7 deletions src/crypto/crypto_common.h
Expand Up @@ -42,17 +42,10 @@ v8::MaybeLocal<v8::Value> GetSSLOCSPResponse(
SSL* ssl,
v8::Local<v8::Value> 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<v8::Value> val);

SSLSessionPointer GetTLSSession(const unsigned char* buf, size_t length);

long VerifyPeerCertificate( // NOLINT(runtime/int)
Expand Down
6 changes: 3 additions & 3 deletions src/crypto/crypto_tls.cc
Expand Up @@ -1667,10 +1667,10 @@ void TLSWrap::SetSession(const FunctionCallbackInfo<Value>& 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<unsigned char> 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");
Expand Down