bnix / double-bag-ftps

Provides a child class of Net::FTP to support implicit and explicit FTPS.
MIT License
48 stars 26 forks source link

Incompatibility with Ruby 2.4.x #17

Open swibowo opened 7 years ago

swibowo commented 7 years ago

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:

Are there any plans to support Ruby 2.4.x ?

Thanks.

Kitton commented 7 years ago

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

sufyanadam commented 7 years ago

@Kitton got the same error as you:

NoMethodError: undefined method 'sync' for # after login method call. Ruby version: 2.4.1

wconrad commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

@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 commented 7 years ago

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

pbrumm commented 7 years ago

I submitted a pull that is working for me on the implicit. https://github.com/bnix/double-bag-ftps/pull/18

jnimety commented 7 years ago

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 commented 7 years ago

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

olbrich commented 6 years ago

Any progress on this?

mileslane commented 6 years ago

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 commented 6 years ago

@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 commented 6 years ago

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 commented 6 years ago

Would this work? https://ftptest.net/ It states it supports implicit FTP over TLS.

-- Confidentiality Notice: This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. From: Wayne Conrad notifications@github.com Reply-To: bnix/double-bag-ftps reply@reply.github.com Date: Friday, March 23, 2018 at 2:01 PM To: bnix/double-bag-ftps double-bag-ftps@noreply.github.com Cc: Miles Lane Miles.Lane@McKesson.com, Comment comment@noreply.github.com Subject: Re: [bnix/double-bag-ftps] Incompatibility with Ruby 2.4.x (#17)

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.

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttp://cp.mcafee.com/d/2DRPoOrhvjhujuKC-rdEEFELcFLLECQkkQnCkT6kjpISrlIl-BaMVsSzF2UHHG7yG1EVtjoupp5jhOUgh5m4XS5jhOqer3xlZPTQ7m77T_QSrdCPpesRG9px6kOrp3BY8gA7UxlIwvVsxF4KXdqCiFhLWoye0Olad-KHY9BShPUVZ4sqejhOrdETvjdCXCQPrNKVJUSyrh, or mute the threadhttp://cp.mcafee.com/d/2DRPoA839J5Zd5VdWWrVISyyCyYOC--yrhhjhupjsphdCPpJmNnWkH3BPqeAbyKKEuaE6zBRdxVBAld7bx14lojLold79EVIe5nTfvgtosvv_jpISrdAVPmEBC4pj9JAenO5pOtBrpOH2CdMESgFqcy7BZrCjMg2PWOFogy1NEaI5wi9g3Eu2U2U3WnI19491dxAHh-pc4AmiewgI18SM31MU2wCrdETvjdCXCQPrNKVJUSyrh.

mileslane commented 6 years ago

What are the requirements for an adequate test server for ongoing development?

Thanks, Miles

-- Confidentiality Notice: This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. From: Wayne Conrad notifications@github.com Reply-To: bnix/double-bag-ftps reply@reply.github.com Date: Friday, March 23, 2018 at 2:01 PM To: bnix/double-bag-ftps double-bag-ftps@noreply.github.com Cc: Miles Lane Miles.Lane@McKesson.com, Comment comment@noreply.github.com Subject: Re: [bnix/double-bag-ftps] Incompatibility with Ruby 2.4.x (#17)

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.

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttp://cp.mcafee.com/d/2DRPoOrhvjhujuKC-rdEEFELcFLLECQkkQnCkT6kjpISrlIl-BaMVsSzF2UHHG7yG1EVtjoupp5jhOUgh5m4XS5jhOqer3xlZPTQ7m77T_QSrdCPpesRG9px6kOrp3BY8gA7UxlIwvVsxF4KXdqCiFhLWoye0Olad-KHY9BShPUVZ4sqejhOrdETvjdCXCQPrNKVJUSyrh, or mute the threadhttp://cp.mcafee.com/d/2DRPoA839J5Zd5VdWWrVISyyCyYOC--yrhhjhupjsphdCPpJmNnWkH3BPqeAbyKKEuaE6zBRdxVBAld7bx14lojLold79EVIe5nTfvgtosvv_jpISrdAVPmEBC4pj9JAenO5pOtBrpOH2CdMESgFqcy7BZrCjMg2PWOFogy1NEaI5wi9g3Eu2U2U3WnI19491dxAHh-pc4AmiewgI18SM31MU2wCrdETvjdCXCQPrNKVJUSyrh.