I'm trying to get FTPFXP to work on Ruby 2.0 (so I can FTP over TLS)
I'm having problems with this line, which sets up the SSL Socket. OpenSSL checks whether @sock is a T_FILE
In Ruby 1.9.3, it worked well, because it was just a TCPSocket but in Ruby 2.0, @sock becomes a Net::FTP::BufferedSocket.
It's easy enough to change the code in https://github.com/codeodor/ftpfxp/blob/06f2d56e65e73d3818b6c7aef4dfe461bad98849/lib/ftpfxp/ftpfxptls.rb#L87 to send @sock.io to make it a TCPSocket again, but when Net::FTP tries to close the socket, it expects the socket to have a read timeout, which I'm guessing BufferedSocket has, but a TCPSocket does not.
So, a few questions:
- Should a
Net::FTP::BufferedSocketbe aFile? - Should Net::FTP be assuming it has a
BufferedSocketat all times? - Should TCPSocket implement
read_timeout?
I guess the broader question is: what is the appropriate fix? Obviously I'll need to work around it in my code, but is this something that should be fixed in Ruby, and if so, where?
Thanks for your help!
So, I thought I'd be clever and set
SSLSocket's@ioafter it was initialized (to skip the type check in the C code):@sock.instance_variable_set(:@io, original_sock)But it was a segfault. 😄 (not when I set it, but when something attempted to use it)