Skip to content

Commit

Permalink
Add ssl context for verification of certs in FTPS hook (#38266)
Browse files Browse the repository at this point in the history
  • Loading branch information
amoghrajesh committed Mar 18, 2024
1 parent 63b58ff commit 884852a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion airflow/providers/ftp/hooks/ftp.py
Expand Up @@ -270,14 +270,18 @@ class FTPSHook(FTPHook):

def get_conn(self) -> ftplib.FTP:
"""Return an FTPS connection object."""
import ssl

if self.conn is None:
params = self.get_connection(self.ftp_conn_id)
pasv = params.extra_dejson.get("passive", True)

if params.port:
ftplib.FTP_TLS.port = params.port

self.conn = ftplib.FTP_TLS(params.host, params.login, params.password) # nosec: B321
# Construct FTP_TLS instance with SSL context to allow certificates to be validated by default
context = ssl.create_default_context()
self.conn = ftplib.FTP_TLS(params.host, params.login, params.password, context=context) # nosec: B321
self.conn.set_pasv(pasv)

return self.conn

0 comments on commit 884852a

Please sign in to comment.