Skip to content

Commit 5d52c43

Browse files
committed
Handle OpenSSL v3 EOF errors
Fix: redis#1106 When Ruby is compiled against OpenSSL V3, if an SSL connection is closed without sending a `close_notify`, a `OpenSSL::SSL::SSLError` will be raised.
1 parent 2f226e5 commit 5d52c43

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/redis/client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ def io
302302
e2 = TimeoutError.new("Connection timed out")
303303
e2.set_backtrace(e1.backtrace)
304304
raise e2
305-
rescue Errno::ECONNRESET, Errno::EPIPE, Errno::ECONNABORTED, Errno::EBADF, Errno::EINVAL => e
305+
rescue Errno::ECONNRESET, Errno::EPIPE, Errno::ECONNABORTED, Errno::EBADF, Errno::EINVAL, EOFError => e
306306
raise ConnectionError, "Connection lost (%s)" % [e.class.name.split("::").last]
307307
end
308308

lib/redis/connection/ruby.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,12 @@ def read
384384
format_reply(reply_type, line)
385385
rescue Errno::EAGAIN
386386
raise TimeoutError
387+
rescue OpenSSL::SSL::SSLError => ssl_error
388+
if ssl_error.message.match?(/SSL_read: unexpected eof while reading/i)
389+
raise EOFError, ssl_error.message
390+
else
391+
raise
392+
end
387393
end
388394

389395
def format_reply(reply_type, line)

0 commit comments

Comments
 (0)