Class: OpenSSL::SSL::SSLServer

Inherits:
Object
  • Object
show all
Includes:
SocketForwarder
Defined in:
lib/openssl/ssl.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SocketForwarder

#addr, #closed?, #do_not_reverse_lookup=, #fcntl, #getsockopt, #peeraddr, #setsockopt

Constructor Details

#initialize(svr, ctx) ⇒ SSLServer

Returns a new instance of SSLServer.



99
100
101
102
103
104
105
106
107
# File 'lib/openssl/ssl.rb', line 99

def initialize(svr, ctx)
  @svr = svr
  @ctx = ctx
  unless ctx.session_id_context
    session_id = OpenSSL::Digest::MD5.hexdigest($0)
    @ctx.session_id_context = session_id
  end
  @start_immediately = true
end

Instance Attribute Details

#start_immediatelyObject

Returns the value of attribute start_immediately.



97
98
99
# File 'lib/openssl/ssl.rb', line 97

def start_immediately
  @start_immediately
end

Instance Method Details

#acceptObject



117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/openssl/ssl.rb', line 117

def accept
  sock = @svr.accept
  begin
    ssl = OpenSSL::SSL::SSLSocket.new(sock, @ctx)
    ssl.sync_close = true
    ssl.accept if @start_immediately
    ssl
  rescue SSLError => ex
    sock.close
    raise ex
  end
end

#closeObject



130
131
132
# File 'lib/openssl/ssl.rb', line 130

def close
  @svr.close
end

#listen(backlog = 5) ⇒ Object



113
114
115
# File 'lib/openssl/ssl.rb', line 113

def listen(backlog=5)
  @svr.listen(backlog)
end

#to_ioObject



109
110
111
# File 'lib/openssl/ssl.rb', line 109

def to_io
  @svr
end