From cccc33b0b4b4ee719fedc5291934d490e50893c3 Mon Sep 17 00:00:00 2001 From: Sam Roberts Date: Thu, 31 Jan 2019 14:34:00 -0800 Subject: [PATCH] src: const_cast is necessary for 1.1.1, not 0.9.7 The const_cast used to be necessary for SSL_get_app_data() in OpenSSL 0.9.7, but node doesn't compile against OpenSSL versions that old. However, now it's needed for the recently introduced SSL_renegotiate_pending(), which is not const-correct as of 1.1.1a. PR-URL: https://github.com/nodejs/node/pull/25861 Reviewed-By: Fedor Indutny Reviewed-By: Anna Henningsen --- src/tls_wrap.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/tls_wrap.cc b/src/tls_wrap.cc index da18522d37b397..ff2f53f15c4ab5 100644 --- a/src/tls_wrap.cc +++ b/src/tls_wrap.cc @@ -210,10 +210,9 @@ void TLSWrap::SSLInfoCallback(const SSL* ssl_, int where, int ret) { if (!(where & (SSL_CB_HANDSHAKE_START | SSL_CB_HANDSHAKE_DONE))) return; - // Be compatible with older versions of OpenSSL. SSL_get_app_data() wants - // a non-const SSL* in OpenSSL <= 0.9.7e. + // SSL_renegotiate_pending() should take `const SSL*`, but it does not. SSL* ssl = const_cast(ssl_); - TLSWrap* c = static_cast(SSL_get_app_data(ssl)); + TLSWrap* c = static_cast(SSL_get_app_data(ssl_)); Environment* env = c->env(); HandleScope handle_scope(env->isolate()); Context::Scope context_scope(env->context());