Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ssl context for verification of certs in FTPS hook #38266

Merged
merged 1 commit into from
Mar 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion airflow/providers/ftp/hooks/ftp.py
Original file line number Diff line number Diff line change
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