mirror of
https://github.com/nodejs/node.git
synced 2026-11-21 12:59:16 -05:00
src: simplify TLSWrap::SetSession
PR-URL: https://github.com/nodejs/node/pull/42087 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com>
This commit is contained in:
1 parent
2cdf8a44e9
commit
0b5e8e01ab
3 files changed
+3
-25
No files matched your search
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in new issue
Block a user