Skip to content

Commit e172c1f

Browse files
committed
[compat] sync up ssl.rb with upstream
1 parent da97ae4 commit e172c1f

File tree

1 file changed

+65
-1
lines changed

1 file changed

+65
-1
lines changed

lib/openssl/ssl.rb

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class SSLContext
138138
def set_params(params={})
139139
params = DEFAULT_PARAMS.merge(params)
140140
self.options = params.delete(:options) # set before min_version/max_version
141-
params.each{|name, value| self.__send__("#{name}=", value) }
141+
params.each{ |name, value| self.__send__("#{name}=", value) }
142142
if self.verify_mode != OpenSSL::SSL::VERIFY_NONE
143143
unless self.ca_file or self.ca_path or self.cert_store
144144
self.cert_store = DEFAULT_CERT_STORE
@@ -245,6 +245,14 @@ def peeraddr
245245
to_io.peeraddr
246246
end
247247

248+
def local_address
249+
to_io.local_address
250+
end
251+
252+
def remote_address
253+
to_io.remote_address
254+
end
255+
248256
def setsockopt(level, optname, optval)
249257
to_io.setsockopt(level, optname, optval)
250258
end
@@ -264,6 +272,36 @@ def closed?
264272
def do_not_reverse_lookup=(flag)
265273
to_io.do_not_reverse_lookup = flag
266274
end
275+
276+
def close_on_exec=(value)
277+
to_io.close_on_exec = value
278+
end
279+
280+
def close_on_exec?
281+
to_io.close_on_exec?
282+
end
283+
284+
def wait(*args)
285+
to_io.wait(*args)
286+
end
287+
288+
def wait_readable(*args)
289+
to_io.wait_readable(*args)
290+
end
291+
292+
def wait_writable(*args)
293+
to_io.wait_writable(*args)
294+
end
295+
296+
if IO.method_defined?(:timeout)
297+
def timeout
298+
to_io.timeout
299+
end
300+
301+
def timeout=(value)
302+
to_io.timeout=(value)
303+
end
304+
end
267305
end
268306

269307
def verify_certificate_identity(cert, hostname)
@@ -419,6 +457,32 @@ def session
419457
nil
420458
end unless method_defined? :session # JRuby
421459

460+
# Close the stream for reading.
461+
# This method is ignored by OpenSSL as there is no reasonable way to
462+
# implement it, but exists for compatibility with IO.
463+
def close_read
464+
# Unsupported and ignored.
465+
# Just don't read any more.
466+
end
467+
468+
# Closes the stream for writing. The behavior of this method depends on
469+
# the version of OpenSSL and the TLS protocol in use.
470+
#
471+
# - Sends a 'close_notify' alert to the peer.
472+
# - Does not wait for the peer's 'close_notify' alert in response.
473+
#
474+
# In TLS 1.2 and earlier:
475+
# - On receipt of a 'close_notify' alert, responds with a 'close_notify'
476+
# alert of its own and close down the connection immediately,
477+
# discarding any pending writes.
478+
#
479+
# Therefore, on TLS 1.2, this method will cause the connection to be
480+
# completely shut down. On TLS 1.3, the connection will remain open for
481+
# reading only.
482+
def close_write
483+
stop
484+
end
485+
422486
private
423487

424488
def using_anon_cipher?

0 commit comments

Comments
 (0)