Provides a child class of Net::FTP to support implicit and explicit FTPS.
Switch branches/tags
Nothing to show
Clone or download
wconrad Merge pull request #14 from dmathieu/close_only_if_open
Only close the ftp connection if it's open
Latest commit 1db868c Jan 2, 2017


DoubleBagFTPS extends the core Net::FTP class to provide implicit and explicit FTPS support.


$ [sudo] gem install double-bag-ftps

Note: Your Ruby installation must have OpenSSL support.


require 'double_bag_ftps'

Example 1:

# Connect to a host using explicit FTPS and do not verify the host's cert
ftps =
ftps.ssl_context = DoubleBagFTPS.create_ssl_context(:verify_mode => OpenSSL::SSL::VERIFY_NONE)
ftps.connect('some host')
ftps.login('usr', 'passwd')

Example 2:'host', 'usr', 'passwd', nil, DoubleBagFTPS::IMPLICIT) do |ftps|


# Constants used for setting FTPS mode
DoubleBagFTPS::IMPLICIT = nil, user = nil, passwd = nil, acct = nil, ftps_mode = EXPLICIT, ssl_context_params = {}), user = nil, passwd = nil, acct = nil, ftps_mode = EXPLICIT, ssl_context_params = {})

# Returns an OpenSSL::SSL::SSLContext using params to set set the corresponding SSLContext attributes.
DoubleBagFTPS.create_ssl_context(params = {})

# Set the FTPS mode to implicit (DoubleBagFTPS::IMPLICIT) or explicit (DoubleBagFTPS::EXPLICIT).
# The default FTPS mode is explicit. 

# Same as Net::FTP.connect, but will use port 990 when using implicit FTPS and a port is not specified.
connect(host, port = ftps_implicit? ? IMPLICIT_PORT : FTP_PORT)

# Same as Net::FTP.login, but with optional auth param to control the value that is sent with the AUTH command.
login(user = 'anonymous', passwd = nil, acct = nil, auth = 'TLS')


More Information


Copyright © 2011, Bryan Nix. DoubleBagFTPS is released under the MIT license. See LICENSE file for details.