Skip to content

Commit 77c3db2

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. It currently clears options in order to avoid setting one of the options included in OpenSSL::SSL::OP_ALL unless explicitly specified, namely OpenSSL::SSL::OP_DONT_INSERT_EMPTY_FRAGMENTS. Now that OpenSSL::SSL::OP_ALL has been removed from SSLContext#initialize, it is no longer necessary.
1 parent 00bec0d commit 77c3db2

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)