You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "potiuk (via GitHub)" <gi...@apache.org> on 2023/08/04 11:46:35 UTC
[GitHub] [airflow] potiuk commented on a diff in pull request #33108: Allows to choose SSL context for IMAP provider
potiuk commented on code in PR #33108:
URL: https://github.com/apache/airflow/pull/33108#discussion_r1284323936
##########
airflow/providers/imap/hooks/imap.py:
##########
@@ -78,16 +79,34 @@ def get_conn(self) -> ImapHook:
return self
def _build_client(self, conn: Connection) -> imaplib.IMAP4_SSL | imaplib.IMAP4:
- IMAP: type[imaplib.IMAP4_SSL] | type[imaplib.IMAP4]
- if conn.extra_dejson.get("use_ssl", True):
- IMAP = imaplib.IMAP4_SSL
- else:
- IMAP = imaplib.IMAP4
-
- if conn.port:
- mail_client = IMAP(conn.host, conn.port)
+ mail_client: imaplib.IMAP4_SSL | imaplib.IMAP4
+ use_ssl = conn.extra_dejson.get("use_ssl", True)
+ if use_ssl:
+ from airflow.configuration import conf
+
+ ssl_context_string = conf.get("imap", "SSL_CONTEXT", fallback=None)
+ if ssl_context_string is None:
+ ssl_context_string = conf.get("email", "SSL_CONTEXT", fallback=None)
+ if ssl_context_string is None:
+ ssl_context_string = "default"
+ if ssl_context_string == "default":
+ ssl_context = ssl.create_default_context()
+ elif ssl_context_string == "none":
Review Comment:
I think this is ok to have lower none and lower default. If we were to be consistent we would have to correct it for the core email and SMTP provider too. Also I think "none" should be discouraged, so I do not want to make it easier for users :)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org