mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-08-01 18:37:42 -05:00
Allow users to set a combined certificte and key file for additional certificates in the SSL context
This commit is contained in:
@@ -395,12 +395,16 @@ def get_mailbox(server, port, security) -> MailBox:
|
||||
"""
|
||||
Returns the correct MailBox instance for the given configuration.
|
||||
"""
|
||||
ssl_context = ssl.create_default_context()
|
||||
if settings.EMAIL_CERTIFICATE_FILE is not None: # pragma: nocover
|
||||
ssl_context.load_cert_chain(certfile=settings.EMAIL_CERTIFICATE_FILE)
|
||||
|
||||
if security == MailAccount.ImapSecurity.NONE:
|
||||
mailbox = MailBoxUnencrypted(server, port)
|
||||
elif security == MailAccount.ImapSecurity.STARTTLS:
|
||||
mailbox = MailBoxTls(server, port, ssl_context=ssl.create_default_context())
|
||||
mailbox = MailBoxTls(server, port, ssl_context=ssl_context)
|
||||
elif security == MailAccount.ImapSecurity.SSL:
|
||||
mailbox = MailBox(server, port, ssl_context=ssl.create_default_context())
|
||||
mailbox = MailBox(server, port, ssl_context=ssl_context)
|
||||
else:
|
||||
raise NotImplementedError("Unknown IMAP security") # pragma: nocover
|
||||
return mailbox
|
||||
|
Reference in New Issue
Block a user