Class
SSLServer
represents a TCP/IP server socket with Secure Sockets Layer.
Attributes
Read & Write
When true then accept
works exactly the same as TCPServer#accept
Class Methods
ext/openssl/lib/openssl/ssl.rb
View on GitHub
# File tmp/rubies/ruby-3.2.0/ext/openssl/lib/openssl/ssl.rb, line 491
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
Creates a new instance of SSLServer
.
-
srv is an instance of
TCPServer
. -
ctx is an instance of
OpenSSL::SSL::SSLContext
.
Instance Methods
#
ext/openssl/lib/openssl/ssl.rb
View on GitHub
# File tmp/rubies/ruby-3.2.0/ext/openssl/lib/openssl/ssl.rb, line 519
def accept
# Socket#accept returns [socket, addrinfo].
# TCPServer#accept returns a socket.
# The following comma strips addrinfo.
sock, = @svr.accept
begin
ssl = OpenSSL::SSL::SSLSocket.new(sock, @ctx)
ssl.sync_close = true
ssl.accept if @start_immediately
ssl
rescue Exception => ex
if ssl
ssl.close
else
sock.close
end
raise ex
end
end
Works similar to TCPServer#accept
.
#
ext/openssl/lib/openssl/ssl.rb
View on GitHub
# File tmp/rubies/ruby-3.2.0/ext/openssl/lib/openssl/ssl.rb, line 540
def close
@svr.close
end
See IO#close
for details.
ext/openssl/lib/openssl/ssl.rb
View on GitHub
# File tmp/rubies/ruby-3.2.0/ext/openssl/lib/openssl/ssl.rb, line 509
def listen(backlog=Socket::SOMAXCONN)
@svr.listen(backlog)
end
See TCPServer#listen
for details.
ext/openssl/lib/openssl/ssl.rb
View on GitHub
# File tmp/rubies/ruby-3.2.0/ext/openssl/lib/openssl/ssl.rb, line 514
def shutdown(how=Socket::SHUT_RDWR)
@svr.shutdown(how)
end
See BasicSocket#shutdown
for details.
#
ext/openssl/lib/openssl/ssl.rb
View on GitHub
# File tmp/rubies/ruby-3.2.0/ext/openssl/lib/openssl/ssl.rb, line 504
def to_io
@svr
end