Project

General

Profile

Bug #9750

OpenSSL::SSL::SSLServer can not accept a Socket as it's first parameter

Added by sstelfox (Sam Stelfox) over 4 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
ruby -v:
ruby 2.2.0dev (2014-04-16 trunk 45603) [x86_64-linux]
[ruby-core:62064]

Description

This could potentially be an issue with a lack of documentation, in which case this may be more appropriate as a feature request.

The first parameter of OpenSSL::SSL::SSLServer#initialize takes a TCPServer without any issue, however, when provided with an instance of Socket that has been created with Socket::SOCK_STREAM (so a standard TCP socket) it breaks with a "wrong argument type Array (expected File)" when attempting to accept a new client. I tracked this down to the difference in return values from TCPServer#accept (returns just a file descriptor) and Socket#accept (which returns an array of file descriptor and address info) and I believe it would be fairly easy to adjust the SSLServer to be able to handle both.

I've attached some sample standalone code that demonstrates the issue and has a work around based on a subclass'd version of SSLServer that can handle both TCPServer and Socket objects. The important lines are 45-58 as well as 85-86. Everything else is setup and support too get those running or are comments. When running without modification it will demonstrate the error. By swapping the comments on 85-86 you can use the adjusted version of SSLServer#accept.

Please let me know if there are any questions, or concerns. I'm happy to help in anyway around this issue.

ssl_server_issue_example.rb (3.38 KB) ssl_server_issue_example.rb sstelfox (Sam Stelfox), 04/16/2014 05:39 PM

Associated revisions

Revision 2dbae9b1
Added by akr (Akira Tanaka) over 4 years ago

  • ext/openssl/lib/openssl/ssl.rb (OpenSSL::SSL::SSLServer#accept): Consider Socket#accept as well as TCPServer#accept. Reported by Sam Stelfox. [Bug #9750]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45863 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 45863
Added by akr (Akira Tanaka) over 4 years ago

  • ext/openssl/lib/openssl/ssl.rb (OpenSSL::SSL::SSLServer#accept): Consider Socket#accept as well as TCPServer#accept. Reported by Sam Stelfox. [Bug #9750]

Revision 45863
Added by akr (Akira Tanaka) over 4 years ago

  • ext/openssl/lib/openssl/ssl.rb (OpenSSL::SSL::SSLServer#accept): Consider Socket#accept as well as TCPServer#accept. Reported by Sam Stelfox. [Bug #9750]

Revision 45863
Added by akr (Akira Tanaka) over 4 years ago

  • ext/openssl/lib/openssl/ssl.rb (OpenSSL::SSL::SSLServer#accept): Consider Socket#accept as well as TCPServer#accept. Reported by Sam Stelfox. [Bug #9750]

Revision 45863
Added by akr (Akira Tanaka) over 4 years ago

  • ext/openssl/lib/openssl/ssl.rb (OpenSSL::SSL::SSLServer#accept): Consider Socket#accept as well as TCPServer#accept. Reported by Sam Stelfox. [Bug #9750]

Revision 45863
Added by akr (Akira Tanaka) over 4 years ago

  • ext/openssl/lib/openssl/ssl.rb (OpenSSL::SSL::SSLServer#accept): Consider Socket#accept as well as TCPServer#accept. Reported by Sam Stelfox. [Bug #9750]

Revision 674b2526
Added by usa (Usaku NAKAMURA) over 4 years ago

merge revision(s) 45863,45871: [Backport #9750]

* ext/openssl/lib/openssl/ssl.rb (OpenSSL::SSL::SSLServer#accept):
  Consider Socket#accept as well as TCPServer#accept.
  Reported by Sam Stelfox.   [Bug #9750]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@46579 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 46579
Added by usa (Usaku NAKAMURA) over 4 years ago

merge revision(s) 45863,45871: [Backport #9750]

* ext/openssl/lib/openssl/ssl.rb (OpenSSL::SSL::SSLServer#accept):
  Consider Socket#accept as well as TCPServer#accept.
  Reported by Sam Stelfox.   [Bug #9750]

Revision 4c5d8beb
Added by nagachika (Tomoyuki Chikanaga) over 4 years ago

merge revision(s) r45863,r45871: [Backport #9750]

* ext/openssl/lib/openssl/ssl.rb (OpenSSL::SSL::SSLServer#accept):
  Consider Socket#accept as well as TCPServer#accept.
  Reported by Sam Stelfox.   [Bug #9750]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46613 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 46613
Added by nagachika (Tomoyuki Chikanaga) over 4 years ago

merge revision(s) r45863,r45871: [Backport #9750]

* ext/openssl/lib/openssl/ssl.rb (OpenSSL::SSL::SSLServer#accept):
  Consider Socket#accept as well as TCPServer#accept.
  Reported by Sam Stelfox.   [Bug #9750]

History

#1 [ruby-core:62445] Updated by akr (Akira Tanaka) over 4 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

Applied in changeset r45863.


  • ext/openssl/lib/openssl/ssl.rb (OpenSSL::SSL::SSLServer#accept): Consider Socket#accept as well as TCPServer#accept. Reported by Sam Stelfox. [Bug #9750]

#2 [ruby-core:62448] Updated by nagachika (Tomoyuki Chikanaga) over 4 years ago

  • Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN to 2.0.0: REQUIRED, 2.1: REQUIRED

I think this introduces no incompatibility and should be backported.

#3 [ruby-core:63360] Updated by usa (Usaku NAKAMURA) over 4 years ago

  • Backport changed from 2.0.0: REQUIRED, 2.1: REQUIRED to 2.0.0: DONE, 2.1: REQUIRED

backported r45863 and r45871 into ruby_2_0_0 at r46579.

#4 [ruby-core:63404] Updated by nagachika (Tomoyuki Chikanaga) over 4 years ago

  • Backport changed from 2.0.0: DONE, 2.1: REQUIRED to 2.0.0: DONE, 2.1: DONE

r45863 and r45871 were backported into ruby_2_1 branch at r46613.

Also available in: Atom PDF