Skip to content

Commit 0b5e8e0

Browse files
authored
src: simplify TLSWrap::SetSession
PR-URL: #42087 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Darshan Sen <[email protected]>
1 parent 2cdf8a4 commit 0b5e8e0

File tree

3 files changed

+3
-25
lines changed

3 files changed

+3
-25
lines changed

src/crypto/crypto_common.cc

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -116,27 +116,12 @@ MaybeLocal<Value> GetSSLOCSPResponse(
116116
return ret;
117117
}
118118

119-
bool SetTLSSession(
120-
const SSLPointer& ssl,
121-
const unsigned char* buf,
122-
size_t length) {
123-
SSLSessionPointer s(d2i_SSL_SESSION(nullptr, &buf, length));
124-
return s == nullptr ? false : SetTLSSession(ssl, s);
125-
}
126-
127119
bool SetTLSSession(
128120
const SSLPointer& ssl,
129121
const SSLSessionPointer& session) {
130122
return session != nullptr && SSL_set_session(ssl.get(), session.get()) == 1;
131123
}
132124

133-
SSLSessionPointer GetTLSSession(Local<Value> val) {
134-
if (!val->IsArrayBufferView())
135-
return SSLSessionPointer();
136-
ArrayBufferViewContents<unsigned char> sbuf(val.As<ArrayBufferView>());
137-
return GetTLSSession(sbuf.data(), sbuf.length());
138-
}
139-
140125
SSLSessionPointer GetTLSSession(const unsigned char* buf, size_t length) {
141126
return SSLSessionPointer(d2i_SSL_SESSION(nullptr, &buf, length));
142127
}

src/crypto/crypto_common.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,10 @@ v8::MaybeLocal<v8::Value> GetSSLOCSPResponse(
4242
SSL* ssl,
4343
v8::Local<v8::Value> default_value);
4444

45-
bool SetTLSSession(
46-
const SSLPointer& ssl,
47-
const unsigned char* buf,
48-
size_t length);
49-
5045
bool SetTLSSession(
5146
const SSLPointer& ssl,
5247
const SSLSessionPointer& session);
5348

54-
SSLSessionPointer GetTLSSession(v8::Local<v8::Value> val);
55-
5649
SSLSessionPointer GetTLSSession(const unsigned char* buf, size_t length);
5750

5851
long VerifyPeerCertificate( // NOLINT(runtime/int)

src/crypto/crypto_tls.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1667,10 +1667,10 @@ void TLSWrap::SetSession(const FunctionCallbackInfo<Value>& args) {
16671667
return THROW_ERR_MISSING_ARGS(env, "Session argument is mandatory");
16681668

16691669
THROW_AND_RETURN_IF_NOT_BUFFER(env, args[0], "Session");
1670-
1671-
SSLSessionPointer sess = GetTLSSession(args[0]);
1670+
ArrayBufferViewContents<unsigned char> sbuf(args[0]);
1671+
SSLSessionPointer sess = GetTLSSession(sbuf.data(), sbuf.length());
16721672
if (sess == nullptr)
1673-
return;
1673+
return; // TODO(tniessen): figure out error handling
16741674

16751675
if (!SetTLSSession(w->ssl_, sess))
16761676
return env->ThrowError("SSL_set_session error");

0 commit comments

Comments
 (0)