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.



161
162
163
164
165
166
167
168
169
170
171
# File 'lib/openssl/ssl.rb', line 161

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_immediatelyObject

Returns the value of attribute start_immediately.



159
160
161
# File 'lib/openssl/ssl.rb', line 159

def start_immediately
  @start_immediately
end

Instance Method Details

#acceptObject



185
186
187
188
189
190
191
192
193
194
195
196
# File 'lib/openssl/ssl.rb', line 185

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



198
199
200
# File 'lib/openssl/ssl.rb', line 198

def close
  @svr.close
end

#listen(backlog = 5) ⇒ Object



177
178
179
# File 'lib/openssl/ssl.rb', line 177

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

#shutdown(how = Socket::SHUT_RDWR) ⇒ Object



181
182
183
# File 'lib/openssl/ssl.rb', line 181

def shutdown(how=Socket::SHUT_RDWR)
  @svr.shutdown(how)
end

#to_ioObject



173
174
175
# File 'lib/openssl/ssl.rb', line 173

def to_io
  @svr
end