Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

class method

OpenSSL::SSL::SSLSocket.new

(*untyped) -> ::OpenSSL::SSL::SSLSocket
SSLSocket.new(io) => aSSLSocket
SSLSocket.new(io, ctx) => aSSLSocket
SSLSocket.new(io, ctx, sync_close:) => aSSLSocket

Creates a new SSL socket from io which must be a real IO object (not an IO-like object that responds to read/write).

If ctx is provided the SSL Sockets initial params will be taken from the context.

The optional sync_close keyword parameter sets the sync_close instance variable. Setting this to true will cause the underlying socket to be closed when the SSL/TLS connection is shut down.

The OpenSSL::Buffering module provides additional IO methods.

This method will freeze the SSLContext if one is provided; however, session management is still allowed in the frozen SSLContext.

See also .open #accept also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0