Class: OpenSSL::SSL::SSLServer

Inherits:
Object
  • Object
show all
Includes:
SocketForwarder
Defined in:
lib/1.8/openssl/ssl-internal.rb,
lib/1.9/openssl/ssl-internal.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.



139
140
141
142
143
144
145
146
147
# File 'lib/1.8/openssl/ssl-internal.rb', line 139

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.



137
138
139
# File 'lib/1.8/openssl/ssl-internal.rb', line 137

def start_immediately
  @start_immediately
end

Instance Method Details

#acceptObject



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

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



174
175
176
# File 'lib/1.8/openssl/ssl-internal.rb', line 174

def close
  @svr.close
end

#listen(backlog = 5) ⇒ Object



153
154
155
# File 'lib/1.8/openssl/ssl-internal.rb', line 153

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

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



157
158
159
# File 'lib/1.8/openssl/ssl-internal.rb', line 157

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

#to_ioObject



149
150
151
# File 'lib/1.8/openssl/ssl-internal.rb', line 149

def to_io
  @svr
end