aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorthekuwayama <thekuwayama@gmail.com>2019-10-31 07:14:57 +0900
committerSamuel Williams <samuel.williams@oriontransfer.co.nz>2019-10-31 14:19:30 +1300
commitdd87110a12dba028ab96ecd885970ba04094f9a4 (patch)
tree714078975d46523c0368d00754d377299e3fc3c4 /lib
parentb9e0c137508ad2f9da52f83db9e8fbbc0b7f4fbe (diff)
downloadruby-openssl-dd87110a12dba028ab96ecd885970ba04094f9a4.tar.gz
add SSLSocket.open
Diffstat (limited to 'lib')
-rw-r--r--lib/openssl/ssl.rb22
1 files changed, 19 insertions, 3 deletions
diff --git a/lib/openssl/ssl.rb b/lib/openssl/ssl.rb
index 8ffd8c74..9f3afc2f 100644
--- a/lib/openssl/ssl.rb
+++ b/lib/openssl/ssl.rb
@@ -442,9 +442,25 @@ YoaOffgTf5qxiwkjnlVZQc3whgnEt9FpVMvQ9eknyeGB5KHfayAc3+hUAvI3/Cr3
end
class << self
- ##
- # open is an alias to ::new
- alias open new
+
+ # call-seq:
+ # open(remote_host, remote_port, context=nil, local_host=nil, local_port=nil)
+ #
+ # Creates a new instance of SSLSocket.
+ # _remote\_host_ and _remote_port_ are used to open TCPSocket.
+ # If _context_ is provided,
+ # the SSL Sockets initial params will be taken from the context.
+ # If _local\_host_ and _local\_port_ are specified,
+ # then those parameters are used on the local end to establish the connection.
+ #
+ # === Example
+ # ctx = OpenSSL::SSL::SSLContext.new
+ # sock = OpenSSL::SSL::SSLSocket.open('localhost', 443, ctx)
+ # sock.connect # Initiates a connection to localhost:443
+ def open(remote_host, remote_port, context=nil, local_host=nil, local_port=nil)
+ sock = ::TCPSocket.open(remote_host, remote_port, local_host, local_port)
+ OpenSSL::SSL::SSLSocket.new(sock, context)
+ end
end
end