Skip to content

Commit

Permalink
tls: add memory tracking support to SSLWrap
Browse files Browse the repository at this point in the history
PR-URL: #30548
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
  • Loading branch information
addaleax authored and targos committed Apr 28, 2020
1 parent 8e829d4 commit 8961d33
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/node_crypto.cc
Expand Up @@ -121,6 +121,7 @@ template void SSLWrap<TLSWrap>::AddMethods(Environment* env,
template void SSLWrap<TLSWrap>::ConfigureSecureContext(SecureContext* sc);
template void SSLWrap<TLSWrap>::SetSNIContext(SecureContext* sc);
template int SSLWrap<TLSWrap>::SetCACerts(SecureContext* sc);
template void SSLWrap<TLSWrap>::MemoryInfo(MemoryTracker* tracker) const;
template SSL_SESSION* SSLWrap<TLSWrap>::GetSessionCallback(
SSL* s,
const unsigned char* key,
Expand Down Expand Up @@ -2488,6 +2489,12 @@ int SSLWrap<Base>::SetCACerts(SecureContext* sc) {
return 1;
}

template <class Base>
void SSLWrap<Base>::MemoryInfo(MemoryTracker* tracker) const {
tracker->TrackField("ocsp_response", ocsp_response_);
tracker->TrackField("sni_context", sni_context_);
}

int VerifyCallback(int preverify_ok, X509_STORE_CTX* ctx) {
// From https://www.openssl.org/docs/man1.1.1/man3/SSL_verify_cb:
//
Expand Down
2 changes: 2 additions & 0 deletions src/node_crypto.h
Expand Up @@ -215,6 +215,8 @@ class SSLWrap {
inline bool is_awaiting_new_session() const { return awaiting_new_session_; }
inline bool is_waiting_cert_cb() const { return cert_cb_ != nullptr; }

void MemoryInfo(MemoryTracker* tracker) const;

protected:
typedef void (*CertCb)(void* arg);

Expand Down
1 change: 1 addition & 0 deletions src/tls_wrap.cc
Expand Up @@ -1240,6 +1240,7 @@ void TLSWrap::GetWriteQueueSize(const FunctionCallbackInfo<Value>& info) {


void TLSWrap::MemoryInfo(MemoryTracker* tracker) const {
SSLWrap<TLSWrap>::MemoryInfo(tracker);
tracker->TrackField("error", error_);
tracker->TrackFieldWithSize("pending_cleartext_input",
pending_cleartext_input_.size(),
Expand Down

0 comments on commit 8961d33

Please sign in to comment.