Skip to content
This repository has been archived by the owner on Oct 15, 2019. It is now read-only.

Incompatibility with Ruby 2.4.x #17

Open
swibowo opened this issue Jun 16, 2017 · 16 comments
Open

Incompatibility with Ruby 2.4.x #17

swibowo opened this issue Jun 16, 2017 · 16 comments

Comments

@swibowo
Copy link

swibowo commented Jun 16, 2017

Ruby 2.4.x introduces TLS support for net/ftp - https://github.com/ruby/ruby/blob/ruby_2_4/lib/net/ftp.rb. The changes in the class functions caused issues with double-bag-ftps extended function.

A couple notable differences:

  • net/ftp only supports explicit FTPS. It doesn't support implicit FTPS
  • net/ftp connect() does 'AUTH TLS' if ssl option is set (conflicts with double-bag-ftps login() function)

Are there any plans to support Ruby 2.4.x ?

Thanks.

@Kitton
Copy link

Kitton commented Jun 29, 2017

I received this NoMethodError: undefined method 'sync' for #<Net::FTP::BufferedSSLSocket:0x00000009d26578> after login method call.
Ruby version: 2.4.1

@sufyanadam
Copy link

@Kitton got the same error as you:

NoMethodError: undefined method 'sync' for #Net::FTP::BufferedSSLSocket:0x00000009d26578 after login method call.
Ruby version: 2.4.1

@wconrad
Copy link
Collaborator

wconrad commented Jul 17, 2017

The ftpd gem depends upon double-bag-ftps for its unit tests, so this issue is a real bother for me. I do plan to fix this eventually, since I'm in the best place to do so (ftpd's unit tests are probably the best automated test of double-bag-ftps that exists right now).

@Kitton
Copy link

Kitton commented Aug 14, 2017

A possible solution can be switching to the native Net::FTP https://ruby-doc.org/stdlib-2.4.0/libdoc/net/ftp/rdoc/Net/FTP.html#method-c-new from double-bag-ftps

@drn
Copy link

drn commented Aug 25, 2017

Ruby 2.4.0 now includes SSL support - Ruby 2.3.0 didn't have this.

DoubleBagFTPS is no longer needed. Looking through the new Net::FTP source code, the change we made was:

  def connection
    @connection ||= (
      ftps = DoubleBagFTPS.new
      ftps.ssl_context = DoubleBagFTPS.create_ssl_context(ssl_context_params)
      ftps.connect(host, port)
      ftps.login(user, password)
      ftps.passive = true
      ftps
    )
  end

to

  def connection
     @connection ||= Net::FTP.new(host, connection_params)
  end

  def connection_params
    {
      port:     port,
      ssl:      ssl_context_params,
      passive:  true,
      username: user,
      password: password
    }
  end

Hope this helps! Prolly worth to note this in the README

@wconrad
Copy link
Collaborator

wconrad commented Aug 25, 2017

@drn @Kitton I think that is mostly true. The last time I looked, I remember finding that the built-in classes do not do implicit TLS. If we can make this library still do that, that would be nice. Even nicer would be figuring out how to use the built-in classes to do implicit TLS, at which point we can thank double-bag-ftps for its long service and put it to rest.

@pbrumm
Copy link

pbrumm commented Aug 30, 2017

I second the need to have implicit support. how can I help.

@pbrumm
Copy link

pbrumm commented Aug 31, 2017

I submitted a pull that is working for me on the implicit.
#18

@jnimety
Copy link

jnimety commented Sep 6, 2017

FWIW this is all I needed to get implicit working with 2.4.1. Feel free to use as a starting point for slimming down double-bag-ftps.

class MyFTP < Net::FTP
  FTP_PORT = 990

  def connect(host, port = FTP_PORT)
    synchronize do
      @host = host
      @bare_sock = open_socket(host, port)
      begin
        ssl_sock = start_tls_session(Socket.tcp(host, port))
        @sock = BufferedSSLSocket.new(ssl_sock, read_timeout: @read_timeout)
        voidresp
        if @private_data_connection
          voidcmd("PBSZ 0")
          voidcmd("PROT P")
        end
      rescue OpenSSL::SSL::SSLError, Net::OpenTimeout
        @sock.close
        raise
      end
    end
  end
end

@jnimety
Copy link

jnimety commented Sep 7, 2017

I should add that the above assumes ssl: true is passed as an initialization option.

@olbrich
Copy link

olbrich commented Jan 26, 2018

Any progress on this?

@mileslane
Copy link

My project is currently blocked moving to Ruby 2.4.2 because of this incompatibility. We are looking into changing our code to remove this dependency, but hope you will release a Ruby 2.4 compatible version of double-bag-ftps before we do the additional work.

@mileslane
Copy link

@wconrad, any chance support for Ruby 2.4.2 will be added in the next month or two? Our project has a dependency on this gem, but we don't have a good test FTPS environment where we can validate work on fixing ruby 2.4.2 support.

@wconrad
Copy link
Collaborator

wconrad commented Mar 23, 2018

I don't have time to work on double-bag-ftps or ftpd right now, so sadly this issue will have to remain unsolved by me.

The real problem is that I no longer have a way to test any changes to double-bag-ftps. Its test suite relied on an external web site that existed just for ftps testing; that web site no longer exists. I haven't had time to come up with a suitable replacement.

@mileslane
Copy link

mileslane commented Mar 23, 2018 via email

@mileslane
Copy link

mileslane commented Mar 23, 2018 via email

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

No branches or pull requests

9 participants