From e9dd17b2d5b9e7530d476f9059393aa232471c80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Mazerand?= Date: Tue, 5 Dec 2023 17:25:58 +0100 Subject: [PATCH] Secure the connection using SSL when connecting to the FTPS server --- smart_open/ftp.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/smart_open/ftp.py b/smart_open/ftp.py index 7d4a5ad5..40d54ca3 100644 --- a/smart_open/ftp.py +++ b/smart_open/ftp.py @@ -10,6 +10,7 @@ """ import logging +import ssl import urllib.parse import smart_open.utils from ftplib import FTP, FTP_TLS, error_reply @@ -85,7 +86,8 @@ def convert_transport_params_to_args(transport_params): def _connect(hostname, username, port, password, secure_connection, transport_params): kwargs = convert_transport_params_to_args(transport_params) if secure_connection: - ftp = FTP_TLS(**kwargs) + ssl_context = ssl.create_default_context(purpose=ssl.Purpose.CLIENT_AUTH) + ftp = FTP_TLS(context=ssl_context, **kwargs) else: ftp = FTP(**kwargs) try: