Skip to content

Commit

Permalink
Secure the connection using SSL when connecting to the FTPS server
Browse files Browse the repository at this point in the history
  • Loading branch information
wammaster committed Dec 5, 2023
1 parent 2894d20 commit e9dd17b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion smart_open/ftp.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"""

import logging
import ssl
import urllib.parse
import smart_open.utils
from ftplib import FTP, FTP_TLS, error_reply
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit e9dd17b

Please sign in to comment.