Class: OpenSSL::SSL::SSLServer
- Inherits:
 - 
      Object
      
        
- Object
 - OpenSSL::SSL::SSLServer
 
 
- Includes:
 - SocketForwarder
 
- Defined in:
 - lib/openssl/ssl.rb
 
Overview
SSLServer represents a TCP/IP server socket with Secure Sockets Layer.
Instance Attribute Summary collapse
- 
  
    
      #start_immediately  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
When true then #accept works exactly the same as TCPServer#accept.
 
Instance Method Summary collapse
- 
  
    
      #accept  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Works similar to TCPServer#accept.
 - 
  
    
      #close  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
See IO#close for details.
 - 
  
    
      #initialize(svr, ctx)  ⇒ SSLServer 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
Creates a new instance of SSLServer.
 - 
  
    
      #listen(backlog = 5)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
See TCPServer#listen for details.
 - 
  
    
      #shutdown(how = Socket::SHUT_RDWR)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
See BasicSocket#shutdown for details.
 - 
  
    
      #to_io  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Returns the TCPServer passed to the SSLServer when initialized.
 
Methods included from SocketForwarder
#addr, #closed?, #do_not_reverse_lookup=, #fcntl, #getsockopt, #peeraddr, #setsockopt
Constructor Details
#initialize(svr, ctx) ⇒ SSLServer
Creates a new instance of SSLServer.
- 
srvis an instance of TCPServer. - 
ctxis an instance of OpenSSL::SSL::SSLContext. 
      254 255 256 257 258 259 260 261 262 263 264  | 
    
      # File 'lib/openssl/ssl.rb', line 254 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).unpack('H*')[0] @ctx.session_id_context = session_id end @start_immediately = true end  | 
  
Instance Attribute Details
#start_immediately ⇒ Object
When true then #accept works exactly the same as TCPServer#accept
      249 250 251  | 
    
      # File 'lib/openssl/ssl.rb', line 249 def start_immediately @start_immediately end  | 
  
Instance Method Details
#accept ⇒ Object
Works similar to TCPServer#accept.
      282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300  | 
    
      # File 'lib/openssl/ssl.rb', line 282 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 ⇒ Object
See IO#close for details.
      303 304 305  | 
    
      # File 'lib/openssl/ssl.rb', line 303 def close @svr.close end  | 
  
#listen(backlog = 5) ⇒ Object
See TCPServer#listen for details.
      272 273 274  | 
    
      # File 'lib/openssl/ssl.rb', line 272 def listen(backlog=5) @svr.listen(backlog) end  | 
  
#shutdown(how = Socket::SHUT_RDWR) ⇒ Object
See BasicSocket#shutdown for details.
      277 278 279  | 
    
      # File 'lib/openssl/ssl.rb', line 277 def shutdown(how=Socket::SHUT_RDWR) @svr.shutdown(how) end  | 
  
#to_io ⇒ Object
Returns the TCPServer passed to the SSLServer when initialized.
      267 268 269  | 
    
      # File 'lib/openssl/ssl.rb', line 267 def to_io @svr end  |