bnix / double-bag-ftps Goto Github PK
View Code? Open in Web Editor NEWProvides a child class of Net::FTP to support implicit and explicit FTPS.
License: MIT License
Provides a child class of Net::FTP to support implicit and explicit FTPS.
License: MIT License
I am trying to use your gem. This is my code:
ftp = DoubleBagFTPS.new
ftp.ftps_mode = DoubleBagFTPS::EXPLICIT
ftp.passive = true
ftp.ssl_context = DoubleBagFTPS.create_ssl_context(:verify_mode => OpenSSL::SSL::VERIFY_NONE)
ftps.connect('ftpssl.autoims.com')
ftps.login('ASEV', 'password')
puts ftps.nlst.first
This is the output that I get:
Net::FTPPermError: 501 Syntax error in 'PORT 10,194,79,186,226,4'
from /home/ubuntu/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/ftp.rb:327:in `getresp'
from /home/ubuntu/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/ftp.rb:339:in `voidresp'
from /home/ubuntu/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/ftp.rb:362:in `block in voidcmd'
from /home/ubuntu/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
from /home/ubuntu/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/ftp.rb:360:in `voidcmd'
from /home/ubuntu/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/ftp.rb:376:in `sendport'
from /home/ubuntu/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/ftp.rb:387:in `makeport'
from /home/ubuntu/.rvm/gems/ruby-2.1.1/gems/double-bag-ftps-0.1.2/lib/double_bag_ftps.rb:111:in `transfercmd'
from /home/ubuntu/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/ftp.rb:515:in `block (2 levels) in retrlines'
from /home/ubuntu/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/ftp.rb:199:in `with_binary'
from /home/ubuntu/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/ftp.rb:513:in `block in retrlines'
from /home/ubuntu/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
from /home/ubuntu/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/ftp.rb:512:in `retrlines'
from /home/ubuntu/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/ftp.rb:745:in `nlst'
from (irb):29
from /home/ubuntu/.rvm/rubies/ruby-2.1.1/bin/irb:11:in `<main>'
Can you give any pointers if I am doing something wrong? Or is the gem possibly not compatible with ruby 2.1.1?
Every time I try to close the connection (after an error state) I get this error.
Here is example code that reproduces the above error:
ftps = DoubleBagFTPS.new
begin
ftps.debug_mode = true
ftps.passive = true
ftps.open_timeout = 1.0
ftps.ftps_mode = DoubleBagFTPS::EXPLICIT
ftps.connect 'ftp.secureftp-test.com'
ftps.login 'test', 'test'
rescue Net::FTPPermError => e
puts e.class
puts e.message
rescue StandardError => e
puts e.class
puts e.message
ensure
ftps.close unless ftps.closed?
end
This seems to be happening in the close
method of Net::FTP:
NoMethodError: undefined method `read_timeout=' for #<TCPSocket:(closed)>
from ~/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/net/ftp.rb:111:in `read_timeout='
from ~/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/net/ftp.rb:960:in `ensure in close'
from ~/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/net/ftp.rb:960:in `close'
I can't determine what DoubleBagFTPS
is doing to cause this, but it doesn't happen if I switch to Net::FTP
.
connect: 192.168.1.1, 990
get: Certificate:
Data:
Version: 3 (0x2)
Serial Number: 0 (0x0)
Signature Algorithm: md5WithRSAEncryption
Issuer: C=US, CN=ftp.XXXXXXXX.com, L=San Francisco, OU=MIS Department, O=XXXXXXXX, ST=CA/[email protected]
Validity
Not Before: Aug 20 17:55:00 2008 GMT
Not After : Aug 20 17:55:00 2020 GMT
Subject: C=US, CN=ftp.XXXXXXXX.com, L=San Francisco, OU=MIS Department, O=XXXXXXXX, ST=CA/[email protected]
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
Public-Key: (1024 bit)
Modulus:
00:db:8d:41:4b:8e:09:ee:58:a6:d4:53:6d:e1:17:
...
60:43:27:7a:17:6e:10:46:1f
Exponent: 65537 (0x10001)
Signature Algorithm: md5WithRSAEncryption
3f:e6:20:2a:f2:be:c1:cb:6c:63:ab:2b:b3:14:c2:04:9f:87:
...
60:43:27:7a:17:6e:10:46:1f
get: 220 GlobalSCAPE Secure FTP Server
put: USER user
get: 331 Password required for user.
put: PASS ********
get: 230 Login OK. Proceed.
put: TYPE I
get: 200 Type set to I.
put: PBSZ 0
get: 200 PBSZ Command OK. Protection buffer size set to 0.
put: PROT P
get: 200 PROT Command OK. Using Private data connection
put: TYPE A
get: 200 Type set to A.
put: PORT 192,168,1,150,4,48
get: 200 Command okay.
put: LIST
get: 150 Opening ASCII mode data connection for file list.
put: TYPE I
The script halted at the line "ftps.list" (see below) until I break it.
Please advise. Thank you.
Here is my script
require 'bundler/setup'
Bundler.require
host = '192.168.1.1'
user = 'user'
passwd = 'password'
ftps = DoubleBagFTPS.new
ftps.ssl_context = DoubleBagFTPS.create_ssl_context(:verify_mode => OpenSSL::SSL::VERIFY_NONE, :ssl_version => "SSLv3")
ftps.debug_mode = true
ftps.ftps_mode = DoubleBagFTPS::IMPLICIT
ftps.connect(host)
ftps.login(user, passwd)
ftps.welcome
ftps.list
ftps.close
@bnix Gem version 0.1.4 is ready for release.
I have been watching an issue that was recently merged into master, but the gem wasn't released in rubygems.org. Any plans to bump the version on RubyGems ?
Using jruby.1.7.16 and double-bag-ftps.0.1.2 on Windows 7.
Jruby does not have support for openssl.session as described in this issue:
GitHub - jruby issue 197
And also in this issue:
GitHub - mechanize issue 207
The following code will result in "NameError: uninitialized constant OpenSSL::SSL::Session from org/jruby/RubyModule.java:2723:in 'const_missing'
require 'double_bag_ftps'
connection = DoubleBagFTPS.new
connection.passive = true
connection.ssl_context = DoubleBagFTPS.create_ssl_context(:verify_mode => OPENSSL::SSL::VERIFY_NONE)
connection.connect('ftps_server')
connection.login('user','pass')
Reverting to version 0.1.1 is my current work-around. I'm hoping that the ability to disable socket reuse will be included in version 0.1.3.
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.
I'm trying to use "double-bag-ftps" gem to connect local machine to ftp server but I met a issue => the code shown below
p 'before ftp'
ftps = DoubleBagFTPS.new
ftps.passive = true
ftps.ftps_mode = DoubleBagFTPS::EXPLICIT
ftps.ssl_context = DoubleBagFTPS.create_ssl_context(:verify_mode => OpenSSL::SSL::VERIFY_NONE)
ftps.connect('xx.xx.xx.xx', '990')
ftps.login('user', 'password')
p 'after ftp'
p 'before filename'
puts ftps.nlst.first
p 'after filename'
the console output:
"before ftp"
DoubleBagFTPS:0x000000032ca378 @ftps_mode=:explicit, @ssl_context=#<OpenSSL::SSL::SSLContext:0x000000032ca030 @cert=nil, @key=nil, @client_ca=nil, @ca_file=nil, @ca_path=nil, @timeout=nil, @verify_mode=0, @verify_depth=nil, @renegotiation_cb=nil, @verify_callback=nil, @options=-2147482625, @cert_store=nil, @extra_chain_cert=nil, @client_cert_cb=nil, @tmp_dh_callback=nil, @session_id_context=nil, @session_get_cb=nil, @session_new_cb=nil, @session_remove_cb=nil, @servername_cb=nil, @npn_protocols=nil, @npn_select_cb=nil>, @mon_owner=nil, @mon_count=0, @mon_mutex=#<Mutex:0x000000032ca0a8>, @binary=true, @passive=true, @debug_mode=false, @resume=false, @sock=#<OpenSSL::SSL::SSLSocket:0x000000032c97c0 @io=#<TCPSocket:fd 7>, @context=#<OpenSSL::SSL::SSLContext:0x000000032ca030 @cert=nil, @key=nil, @client_ca=nil, @ca_file=nil, @ca_path=nil, @timeout=nil, @verify_mode=0, @verify_depth=nil, @renegotiation_cb=nil, @verify_callback=nil, @options=-2147482625, @cert_store=nil, @extra_chain_cert=nil, @client_cert_cb=nil, @tmp_dh_callback=nil, @session_id_context=nil, @session_get_cb=nil, @session_new_cb=nil, @session_remove_cb=nil, @servername_cb=nil, @npn_protocols=nil, @npn_select_cb=nil>, @sync_close=true, @hostname=nil, @eof=false, @rbuffer="", @sync=true, @callback_state=nil, @wbuffer="">, @logged_in=true, @open_timeout=nil, @read_timeout=60, @hostname="xx.xx.xx.xx", @last_response="200 PROT now Private.\n", @last_response_code="200", @ssl_session=#<OpenSSL::SSL::Session:0x000000032c9720>, @welcome="230 Login successful.\n">
"after ftp"
"before filename"
/brabra/lib/double_bag_ftps.rb:83:in `initialize': Connection timed out - connect(2) (Errno::ETIMEDOUT)
login to ftps server works fine but it will stuck at "fetching first file name" in ftp server and result is timeout... No idea about this and very thanks.
One server that I'm trying to get a file is returning a private address with passive mode in a Explicit tls connection, I've made a simple addition to solve the issue if the address is private.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.