Skip to content

ssl: support SSLSocket#connect and #accept with timeout - #1098

Open
rhenium wants to merge 2 commits into
ruby:masterfrom
rhenium:ky/ssl-handshake-timeout
Open

ssl: support SSLSocket#connect and #accept with timeout#1098
rhenium wants to merge 2 commits into
ruby:masterfrom
rhenium:ky/ssl-handshake-timeout

Conversation

@rhenium

@rhenium rhenium commented Aug 27, 2026

Copy link
Copy Markdown
Member

Add a keyword argument timeout to specify the total time allowed for the TLS handshake to complete. Inspired by Addrinfo#connect(timeout:) and TCPSocket.open(connect_timeout:).

Applies on top of #1105

Let the extension only provide the most basic non-blocking form,
SSLSocket#ssl_connect, #ssl_accept, #ssl_read, #ssl_write.

Implement SSLSocket#connect, #accept, #sysread, and #syswrite in
lib/openssl/ssl.rb on top of these primitives and #wait_{read,writ}able.

Also, handle the keyword arguments for the public #*_nonblock methods
in Ruby to simplify and to avoid the Hash allocation.

This prepares for the upcoming changes to SSLSocket to add proper
timeout support and socket closed state tracking. These would be easier
to do in Ruby.

No user-visible behavior change is intended with this patch.
Add a keyword argument timeout to specify the total time allowed for
the TLS handshake to complete. Inspired by Addrinfo#connect(timeout:)
and TCPSocket.open(connect_timeout:).
@rhenium
rhenium force-pushed the ky/ssl-handshake-timeout branch from 76bc4f0 to 2cf80fe Compare September 2, 2026 12:48
@ioquatix

ioquatix commented Sep 2, 2026

Copy link
Copy Markdown
Member

Do you default to IO#timeout where appropriate? wait_readable and wait_writable will use the default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants