From de06480f4fce951ee85fc6f98dbda5463dc5bfbb Mon Sep 17 00:00:00 2001 From: Joe Vennix Date: Thu, 23 Jan 2014 14:51:42 -0600 Subject: [PATCH] Add a defined? check to fix older versions of OpenSSL. Older versions of OpenSSL did not export the OP_NO_COMPRESSION constant, so users running metasploit on systems with old copies of openssl would throw a NameError since the constant did not exist. --- lib/rex/socket/ssl_tcp_server.rb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/rex/socket/ssl_tcp_server.rb b/lib/rex/socket/ssl_tcp_server.rb index 2f96cfbaaa..317b98313e 100644 --- a/lib/rex/socket/ssl_tcp_server.rb +++ b/lib/rex/socket/ssl_tcp_server.rb @@ -154,11 +154,15 @@ module Rex::Socket::SslTcpServer ctx.cert = cert ctx.options = 0 - # enable/disable the SSL/TLS-level compression - if params.ssl_compression - ctx.options &= ~OpenSSL::SSL::OP_NO_COMPRESSION - else - ctx.options |= OpenSSL::SSL::OP_NO_COMPRESSION + + # Older versions of OpenSSL do not export the OP_NO_COMPRESSION symbol + if defined?(OpenSSL::SSL::OP_NO_COMPRESSION) + # enable/disable the SSL/TLS-level compression + if params.ssl_compression + ctx.options &= ~OpenSSL::SSL::OP_NO_COMPRESSION + else + ctx.options |= OpenSSL::SSL::OP_NO_COMPRESSION + end end ctx.session_id_context = Rex::Text.rand_text(16)