From 8961d33afff63806044912ba3c1f3a53c75f27a1 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Tue, 19 Nov 2019 20:06:50 +0100 Subject: [PATCH] tls: add memory tracking support to SSLWrap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/30548 Reviewed-By: Ben Noordhuis Reviewed-By: David Carlier Reviewed-By: James M Snell Reviewed-By: Tobias Nießen --- src/node_crypto.cc | 7 +++++++ src/node_crypto.h | 2 ++ src/tls_wrap.cc | 1 + 3 files changed, 10 insertions(+) diff --git a/src/node_crypto.cc b/src/node_crypto.cc index ee42630ad06da9..3e956098e48666 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -121,6 +121,7 @@ template void SSLWrap::AddMethods(Environment* env, template void SSLWrap::ConfigureSecureContext(SecureContext* sc); template void SSLWrap::SetSNIContext(SecureContext* sc); template int SSLWrap::SetCACerts(SecureContext* sc); +template void SSLWrap::MemoryInfo(MemoryTracker* tracker) const; template SSL_SESSION* SSLWrap::GetSessionCallback( SSL* s, const unsigned char* key, @@ -2488,6 +2489,12 @@ int SSLWrap::SetCACerts(SecureContext* sc) { return 1; } +template +void SSLWrap::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: // diff --git a/src/node_crypto.h b/src/node_crypto.h index 74ae4025da9f33..dd043813fa22cd 100644 --- a/src/node_crypto.h +++ b/src/node_crypto.h @@ -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); diff --git a/src/tls_wrap.cc b/src/tls_wrap.cc index 36877424216ed4..47563366dbae51 100644 --- a/src/tls_wrap.cc +++ b/src/tls_wrap.cc @@ -1240,6 +1240,7 @@ void TLSWrap::GetWriteQueueSize(const FunctionCallbackInfo& info) { void TLSWrap::MemoryInfo(MemoryTracker* tracker) const { + SSLWrap::MemoryInfo(tracker); tracker->TrackField("error", error_); tracker->TrackFieldWithSize("pending_cleartext_input", pending_cleartext_input_.size(),