Skip to content

Commit

Permalink
Avoid mutating SSLContext in SSLServer.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Apr 21, 2024
1 parent d3d857c commit 6d08940
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions lib/openssl/ssl.rb
Expand Up @@ -147,11 +147,22 @@ def set_params(params={})
params = DEFAULT_PARAMS.merge(params)
self.options = params.delete(:options) # set before min_version/max_version
params.each{|name, value| self.__send__("#{name}=", value) }

# Set the default certificate store if we're verifying certificates:
if self.verify_mode != OpenSSL::SSL::VERIFY_NONE
unless self.ca_file or self.ca_path or self.cert_store
self.cert_store = DEFAULT_CERT_STORE
end
end

# Set the default session id context if it's not set:
unless self.session_id_context
# see #6137 - session id may not exceed 32 bytes
prng = ::Random.new($0.hash)
session_id = prng.bytes(16).unpack1('H*')
self.session_id_context = session_id
end

return params
end

Expand Down Expand Up @@ -529,12 +540,6 @@ class SSLServer
def initialize(svr, ctx)
@svr = svr
@ctx = ctx
unless ctx.session_id_context
# see #6137 - session id may not exceed 32 bytes
prng = ::Random.new($0.hash)
session_id = prng.bytes(16).unpack1('H*')
@ctx.session_id_context = session_id
end
@start_immediately = true
end

Expand Down

0 comments on commit 6d08940

Please sign in to comment.