From: Trenton H <797416+stumpylog@users.noreply.github.com> Date: Thu, 27 Jul 2023 22:07:59 +0000 (-0700) Subject: Creates and provides a default SSL context to the IMAP library X-Git-Tag: v1.17.0~1^2~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b715e4d426f598694d50b46e3e60108d24649eda;p=thirdparty%2Fpaperless-ngx.git Creates and provides a default SSL context to the IMAP library --- diff --git a/src/paperless_mail/mail.py b/src/paperless_mail/mail.py index 65768d3c24..a0bda19ba5 100644 --- a/src/paperless_mail/mail.py +++ b/src/paperless_mail/mail.py @@ -2,6 +2,7 @@ import datetime import itertools import logging import os +import ssl import tempfile import traceback from datetime import date @@ -394,13 +395,12 @@ def get_mailbox(server, port, security) -> MailBox: """ Returns the correct MailBox instance for the given configuration. """ - if security == MailAccount.ImapSecurity.NONE: mailbox = MailBoxUnencrypted(server, port) elif security == MailAccount.ImapSecurity.STARTTLS: - mailbox = MailBoxTls(server, port) + mailbox = MailBoxTls(server, port, ssl_context=ssl.create_default_context()) elif security == MailAccount.ImapSecurity.SSL: - mailbox = MailBox(server, port) + mailbox = MailBox(server, port, ssl_context=ssl.create_default_context()) else: raise NotImplementedError("Unknown IMAP security") # pragma: nocover return mailbox