Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSL doesn't work after setting TCPSocket = EventMachine::Synchrony::TCPSocket #82

Open
tobowers opened this issue Nov 9, 2011 · 7 comments
Labels

Comments

@tobowers
Copy link

tobowers commented Nov 9, 2011

minimum to reproduce:

EM.synchrony do
  TCPSocket = EventMachine::Synchrony::TCPSocket
  obj = Net::HTTP.new("google.com", 443)
  obj.use_ssl = true
  obj.verify_mode = OpenSSL::SSL::VERIFY_NONE
  obj.get("/")
  EM.stop
end

triggers:

ruby-1.9.2-p290/lib/ruby/1.9.1/net/http.rb:658:in `initialize': wrong argument type EventMachine::Synchrony::TCPSocket (expected File) (TypeError)
    from /Users/topper/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/http.rb:658:in `new'
    from /Users/topper/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/http.rb:658:in `connect'
    from /Users/topper/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/http.rb:637:in `do_start'
    from /Users/topper/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/http.rb:626:in `start'
    from /Users/topper/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/http.rb:1168:in `request'
    from /Users/topper/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/http.rb:888:in `get'

@igrigorik
Copy link
Owner

Unfortunately that's not surprising. Existing TCPSocket functionality is very basic, as in it only implements a few methods of the API. The SSL stuff specifically shouldn't be hard to add, but yeah.. I wouldn't even call it a bug, but rather a feature request.

(I should document that TCPSocket class more to be explicit about the minimal functionality)

@CodeMonkeySteve
Copy link
Collaborator

I dug into the Ruby C code and it looks like it's failing in SSLSocket because the passed socket isn't a File, i.e. "Check_Type(io, T_FILE)". I don't know how it can work with the original TCPSocket class (which is also not a File).

For whatever it's worth, it doesn't look like EM::TCPSocket is missing anything, it's just that SSL is unreasonably picky about the socket type.

@igrigorik
Copy link
Owner

Well, I don't think we would want to try to wrap that, we need to use the built-in EM SSL primitives.. which is actually as simple as conn.start_tls(opts). Having said that, looking at net/http, this may mean that we would have to do some heavy patching of the connect method (ugh): https://github.com/ruby/ruby/blob/trunk/lib/net/http.rb#L760-810

@tnachen
Copy link

tnachen commented May 8, 2012

Is this still on the radar of getting worked on or just sitting in the backlog for now? Would really like this to be implemented. Thanks!

@igrigorik
Copy link
Owner

It's definitely on the backlog, and to be honest.. unlikely to be resolved. I don't think we'll be able to match the SSL API's.

@tnachen
Copy link

tnachen commented May 9, 2012

Is it because there is no time for this or just technical impossible? From the comments it sounded like it's doable.

@igrigorik
Copy link
Owner

EM's SSL layer and net/http SSL layer are two entirely different beasts.. Perhaps it come be made to work, but I'm not too hopeful. I have a strong feeling that even if we do get the basic case to work, we'll end up running into all kinds of edge cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants