Class: OpenSSL::SSL::SSLServer
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Instance Chain:
self,
SocketForwarder
|
|
Inherits: | Object |
Defined in: | ext/openssl/lib/openssl/ssl.rb |
Overview
SSLServer
represents a TCP/IP server socket with Secure Sockets Layer.
Class Method Summary
-
.new(svr, ctx) ⇒ SSLServer
constructor
Creates a new instance of
SSLServer
.
Instance Attribute Summary
-
#start_immediately
rw
When true then #accept works exactly the same as
TCPServer#accept
SocketForwarder
- Included
Instance Method Summary
-
#accept
Works similar to
TCPServer#accept
. -
#close
See
IO#close
for details. -
#listen(backlog = Socket::SOMAXCONN)
See
TCPServer#listen
for details. -
#shutdown(how = Socket::SHUT_RDWR)
See
BasicSocket#shutdown
for details. -
#to_io
Returns the TCPServer passed to the
SSLServer
when initialized.
SocketForwarder
- Included
#addr, #fcntl, | |
#fileno | The file descriptor for the socket. |
#getsockopt, #local_address, #peeraddr, #remote_address, #setsockopt, #wait, #wait_readable, #wait_writable |
Constructor Details
.new(svr, ctx) ⇒ SSLServer
Creates a new instance of SSLServer
.
-
srv is an instance of TCPServer.
-
ctx is an instance of
SSLContext
.
# File 'ext/openssl/lib/openssl/ssl.rb', line 555
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
Instance Attribute Details
#start_immediately (rw)
When true then #accept works exactly the same as TCPServer#accept
# File 'ext/openssl/lib/openssl/ssl.rb', line 550
attr_accessor :start_immediately
Instance Method Details
#accept
Works similar to TCPServer#accept
.
# File 'ext/openssl/lib/openssl/ssl.rb', line 583
def accept # Socket#accept returns [socket, addrinfo]. # TCPServer#accept returns a socket. # The following comma strips addrinfo. sock, = @svr.accept begin ssl = OpenSSL::SSL::SSLSocket.new(sock, @ctx) ssl.sync_close = true ssl.accept if @start_immediately ssl rescue Exception => ex if ssl ssl.close else sock.close end raise ex end end
#close
See IO#close
for details.
# File 'ext/openssl/lib/openssl/ssl.rb', line 604
def close @svr.close end
#listen(backlog = Socket::SOMAXCONN)
See TCPServer#listen
for details.
# File 'ext/openssl/lib/openssl/ssl.rb', line 573
def listen(backlog=Socket::SOMAXCONN) @svr.listen(backlog) end
#shutdown(how = Socket::SHUT_RDWR)
See BasicSocket#shutdown
for details.
# File 'ext/openssl/lib/openssl/ssl.rb', line 578
def shutdown(how=Socket::SHUT_RDWR) @svr.shutdown(how) end
#to_io
Returns the TCPServer passed to the SSLServer
when initialized.
# File 'ext/openssl/lib/openssl/ssl.rb', line 568
def to_io @svr end