2019-07-16 18:53:28 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2012-08-02 18:03:52 -04:00
|
|
|
require 'openssl'
|
|
|
|
|
|
|
|
module OpenSSL
|
|
|
|
module SSL
|
2012-08-11 18:09:09 -04:00
|
|
|
class SSLServer
|
|
|
|
unless public_method_defined? :accept_nonblock
|
2012-08-02 18:03:52 -04:00
|
|
|
def accept_nonblock
|
|
|
|
sock = @svr.accept_nonblock
|
|
|
|
|
|
|
|
begin
|
|
|
|
ssl = OpenSSL::SSL::SSLSocket.new(sock, @ctx)
|
|
|
|
ssl.sync_close = true
|
|
|
|
ssl.accept if @start_immediately
|
|
|
|
ssl
|
|
|
|
rescue SSLError => ex
|
2019-09-02 03:15:25 -04:00
|
|
|
if ssl
|
|
|
|
ssl.close
|
|
|
|
else
|
|
|
|
sock.close
|
|
|
|
end
|
2012-08-02 18:03:52 -04:00
|
|
|
raise ex
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|