Anyone get working FTPS/FTP::TLS Under Ruby 1.9.3?

两盒软妹~` 提交于 2019-12-12 00:37:54

问题


I've tried several gems, examples, etc, and cannot get this working, the more promising gems were: double-bag-ftps and FTPFXP, I can connect but I cannot transfer files, in active or passive mode..

sample code with ftpfxp:

@conn2 = Net::FTPFXPTLS.new
@conn2.passive = true
@conn2.debug_mode = true
@conn2.connect('192.168.0.2', 990)
@conn2.login('myuser2', 'mypass2')
@conn2.chdir('/')
@conn2.get("data.txt")
@conn2.close

sample code with double-bag:

ftps = DoubleBagFTPS.new
ftps.ssl_context = DoubleBagFTPS.create_ssl_context(:verify_mode => OpenSSL::SSL::VERIFY_NONE)
ftps.connect('192.168.0.2')
ftps.login('myuser2', 'mypass2')
ftps.chdir('/')
ftps.get("data.txt")
ftps.close 

sample error with double-bag:

~/.rbenv/versions/1.9.3-p385/lib/ruby/gems/1.9.1/gems/double-bag-ftps-0.1.0/lib/double_bag_ftps.rb:148:in `connect': Broken pipe - SSL_connect (Errno::EPIPE)

Sample error with ftpfxp:

~/.rbenv/versions/1.9.3-p385/lib/ruby/1.9.1/net/ftp.rb:206:in `initialize': No route to host - connect(2) (Errno::EHOSTUNREACH)

Any recomendation that does not involve external commands ?

Thanks.


回答1:


I've solved the issue, the server was returning a private ip address while trying to connect in pasive mode with Explicit tls, so I've added a line to Double-Bag-FTPS to check if the returned ip was private fallback to the original public ip address...

GitHub Pull request

So if someone has the same issue maybe this is the answer hope that this can help someone else :)



来源:https://stackoverflow.com/questions/15259199/anyone-get-working-ftps-ftptls-under-ruby-1-9-3

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!