This class wraps another ::Socket::Server
in an SSL layer.
require "socket" require "openssl" tcp_server = TCPServer.new(0) ssl_context = OpenSSL::SSL::Context::Server.new ssl_context.certificate_chain = "openssl.crt" ssl_context.private_key = "openssl.key" ssl_server = OpenSSL::SSL::Server.new(tcp_server, ssl_context) puts "SSL Server listening on #{tcp_server.local_address}" while connection = ssl_server.accept? connection.puts "secure message" connection.close end
Creates a new SSL server wrapping wrapped.
Creates a new SSL server wrapping wrapped and yields it to the block.
Implements ::Socket::Server#accept
.
Implements ::Socket::Server#accept?
.
Closes this SSL server.
Returns true
if this SSL server has been closed.
Returns the SSL context.
Returns local address of #wrapped
.
When true
a call to #accept
will also initiate the SSL handshake.
When true
a call to #accept
will also initiate the SSL handshake.
If #sync_close?
is true
, closing this server will close the wrapped server.
If #sync_close?
is true
, closing this server will close the wrapped server.
Returns the wrapped server socket.
Socket::Server
Reference
Reference
Object
Object
Creates a new SSL server wrapping wrapped.
context configures the SSL options, see OpenSSL::SSL::Context::Server
for details
Creates a new SSL server wrapping wrapped and yields it to the block.
context configures the SSL options, see OpenSSL::SSL::Context::Server
for details
The server is closed after the block returns.
Implements ::Socket::Server#accept
.
This method calls @wrapped.accept
and wraps the resulting IO in a SSL socket (OpenSSL::SSL::Socket::Server
) with #context
configuration.
Implements ::Socket::Server#accept?
.
This method calls @wrapped.accept?
and wraps the resulting IO in a SSL socket (OpenSSL::SSL::Socket::Server
) with #context
configuration.
Returns the SSL context.
Returns local address of #wrapped
.
When true
a call to #accept
will also initiate the SSL handshake.
When true
a call to #accept
will also initiate the SSL handshake.
If #sync_close?
is true
, closing this server will close the wrapped server.
If #sync_close?
is true
, closing this server will close the wrapped server.
Returns the wrapped server socket.
© 2012–2020 Manas Technology Solutions.
Licensed under the Apache License, Version 2.0.
https://crystal-lang.org/api/0.35.1/OpenSSL/SSL/Server.html