Skip to content

Commit de06480

Browse files
committed
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.
1 parent b5f6102 commit de06480

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

lib/rex/socket/ssl_tcp_server.rb

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,15 @@ def makessl(params)
154154
ctx.cert = cert
155155
ctx.options = 0
156156

157-
# enable/disable the SSL/TLS-level compression
158-
if params.ssl_compression
159-
ctx.options &= ~OpenSSL::SSL::OP_NO_COMPRESSION
160-
else
161-
ctx.options |= OpenSSL::SSL::OP_NO_COMPRESSION
157+
158+
# Older versions of OpenSSL do not export the OP_NO_COMPRESSION symbol
159+
if defined?(OpenSSL::SSL::OP_NO_COMPRESSION)
160+
# enable/disable the SSL/TLS-level compression
161+
if params.ssl_compression
162+
ctx.options &= ~OpenSSL::SSL::OP_NO_COMPRESSION
163+
else
164+
ctx.options |= OpenSSL::SSL::OP_NO_COMPRESSION
165+
end
162166
end
163167

164168
ctx.session_id_context = Rex::Text.rand_text(16)

0 commit comments

Comments
 (0)