Skip to content

Commit

Permalink
Introduced Safer FTP Alternative: Added FTP_TLS (#15137)
Browse files Browse the repository at this point in the history
Added `FTP_TLS` as an option

Signed-off-by: fazledyn-or <ataf@openrefactory.com>
  • Loading branch information
fazledyn-or authored Nov 20, 2023
1 parent 7f80c3b commit c106acc
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions conan/tools/files/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def get(conanfile, url, md5=None, sha1=None, sha256=None, destination=".", filen
os.unlink(filename)


def ftp_download(conanfile, host, filename, login='', password=''):
def ftp_download(conanfile, host, filename, login='', password='', secure=False):
"""
Ftp download of a file. Retrieves a file from an FTP server. This doesn’t support SSL, but you
might implement it yourself using the standard Python FTP library.
Expand All @@ -142,7 +142,11 @@ def ftp_download(conanfile, host, filename, login='', password=''):
import ftplib
ftp = None
try:
ftp = ftplib.FTP(host)
if secure:
ftp = ftplib.FTP_TLS(host)
ftp.prot_p()
else:
ftp = ftplib.FTP(host)
ftp.login(login, password)
filepath, filename = os.path.split(filename)
if filepath:
Expand Down

0 comments on commit c106acc

Please sign in to comment.