class OpenSSL::SSL::SSLServer
SSLServer represents a TCP/IP server socket with Secure Sockets Layer.
Deprecated. Use TCPServer or Socket to accept a TCP connection, and then wrap it with OpenSSL::SSL::SSLSocket. See also OpenSSL::SSL::SSLSocket#accept.
Attributes
When set to true, accept will immediately perform the SSL/TLS handshake after accepting a TCP connection. Defaults to true.
NOTE: accept performs the SSL/TLS handshake synchronously. A slow client can therefore prevent the server from accepting new connections indefinitely. For this reason, SSLServer is deprecated.
Public Class Methods
Source
# File ext/openssl/lib/openssl/ssl.rb, line 496 def initialize(svr, ctx) @svr = svr @ctx = ctx if !ctx.frozen? && !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
Creates a new instance of SSLServer.
-
srv is an instance of
TCPServer. -
ctx is an instance of
OpenSSL::SSL::SSLContext.
Public Instance Methods
Source
# File ext/openssl/lib/openssl/ssl.rb, line 526 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
Works similar to TCPServer#accept.
NOTE: SSLServer is deprecated. See start_immediately for details.
Source
# File ext/openssl/lib/openssl/ssl.rb, line 547 def close @svr.close end
See IO#close for details.
# File ext/openssl/lib/openssl/ssl.rb, line 514 def listen(backlog=Socket::SOMAXCONN) @svr.listen(backlog) end
See TCPServer#listen for details.
# File ext/openssl/lib/openssl/ssl.rb, line 519 def shutdown(how=Socket::SHUT_RDWR) @svr.shutdown(how) end
See BasicSocket#shutdown for details.