Skip to content

Commit fc6d2c1

Browse files
committed
ssl: do not clear existing SSL options in SSLContext#set_params
Apply SSL options set in DEFAULT_PARAMS without clearing existing options, which may be set by a system-wide configuration file. With a fresh installation of OpenSSL 3.3.1, this change will enable the OpenSSL::SSL::OP_ENABLE_MIDDLEBOX_COMPAT option for users of SSLContext#set_params.
1 parent c6c3543 commit fc6d2c1

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

lib/openssl/ssl.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def initialize(version = nil)
144144
# used.
145145
def set_params(params={})
146146
params = DEFAULT_PARAMS.merge(params)
147-
self.options = params.delete(:options) # set before min_version/max_version
147+
self.options |= params.delete(:options) # set before min_version/max_version
148148
params.each{|name, value| self.__send__("#{name}=", value) }
149149
if self.verify_mode != OpenSSL::SSL::VERIFY_NONE
150150
unless self.ca_file or self.ca_path or self.cert_store

test/openssl/test_ssl.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ def test_ctx_options_config
5757
assert_separately([{ "OPENSSL_CONF" => f.path }, "-ropenssl"], <<~"end;")
5858
ctx = OpenSSL::SSL::SSLContext.new
5959
assert_equal OpenSSL::SSL::OP_NO_TICKET, ctx.options & OpenSSL::SSL::OP_NO_TICKET
60+
ctx.set_params
61+
assert_equal OpenSSL::SSL::OP_NO_TICKET, ctx.options & OpenSSL::SSL::OP_NO_TICKET
6062
end;
6163
}
6264
end

0 commit comments

Comments
 (0)