Class: OpenSSL::SSL::SSLServer

Inherits:
Object
  • Object
show all
Includes:
SocketForwarder
Defined in:
lib/extensions/openssl/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.



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

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.



138
139
140
# File 'lib/extensions/openssl/openssl/ssl-internal.rb', line 138

def start_immediately
  @start_immediately
end

Instance Method Details

#acceptObject



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

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



175
176
177
# File 'lib/extensions/openssl/openssl/ssl-internal.rb', line 175

def close
  @svr.close
end

#listen(backlog = 5) ⇒ Object



154
155
156
# File 'lib/extensions/openssl/openssl/ssl-internal.rb', line 154

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

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



158
159
160
# File 'lib/extensions/openssl/openssl/ssl-internal.rb', line 158

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

#to_ioObject



150
151
152
# File 'lib/extensions/openssl/openssl/ssl-internal.rb', line 150

def to_io
  @svr
end