diff options
author | Caolán McNamara <caolan.mcnamara@collabora.com> | 2023-07-28 12:13:41 +0100 |
---|---|---|
committer | Thorsten Behrens <thorsten.behrens@allotropia.de> | 2023-07-29 02:30:34 +0200 |
commit | e3d28846c2343072750197fcdeaf44a945ddcb61 (patch) | |
tree | e3758bf1adfb530f5193abf1e648fa09fe826870 | |
parent | 2f9c1990a85b0e867400f5952095704e178680ad (diff) |
follow python recommendation and pass SSL contexts
i.e. https://docs.python.org/3/library/ssl.html#security-considerations
Change-Id: I67a0f9e1c25abc6644412b014f30933a7e681da2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155016
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
-rw-r--r-- | scripting/source/pyprov/mailmerge.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/scripting/source/pyprov/mailmerge.py b/scripting/source/pyprov/mailmerge.py index 0ef37b477c81..6bd80430d147 100644 --- a/scripting/source/pyprov/mailmerge.py +++ b/scripting/source/pyprov/mailmerge.py @@ -47,7 +47,7 @@ from email.utils import formatdate from email.utils import parseaddr from socket import _GLOBAL_DEFAULT_TIMEOUT -import sys, smtplib, imaplib, poplib +import sys, ssl, smtplib, imaplib, poplib dbg = False # pythonloader looks for a static g_ImplementationHelper variable @@ -96,7 +96,7 @@ class PyMailSMTPService(unohelper.Base, XSmtpService): if dbg: print("Timeout: " + str(tout), file=sys.stderr) if port == 465: - self.server = smtplib.SMTP_SSL(server, port,timeout=tout) + self.server = smtplib.SMTP_SSL(server, port, timeout=tout, context=ssl.create_default_context()) else: self.server = smtplib.SMTP(server, port,timeout=tout) @@ -108,7 +108,7 @@ class PyMailSMTPService(unohelper.Base, XSmtpService): print("ConnectionType: " + connectiontype, file=sys.stderr) if connectiontype.upper() == 'SSL' and port != 465: self.server.ehlo() - self.server.starttls() + self.server.starttls(context=ssl.create_default_context()) self.server.ehlo() user = xAuthenticator.getUserName() @@ -299,7 +299,7 @@ class PyMailIMAPService(unohelper.Base, XMailService): print(connectiontype, file=sys.stderr) print("BEFORE", file=sys.stderr) if connectiontype.upper() == 'SSL': - self.server = imaplib.IMAP4_SSL(server, port) + self.server = imaplib.IMAP4_SSL(server, port, ssl_context=ssl.create_default_context()) else: self.server = imaplib.IMAP4(server, port) print("AFTER", file=sys.stderr) @@ -368,7 +368,7 @@ class PyMailPOP3Service(unohelper.Base, XMailService): print(connectiontype, file=sys.stderr) print("BEFORE", file=sys.stderr) if connectiontype.upper() == 'SSL': - self.server = poplib.POP3_SSL(server, port) + self.server = poplib.POP3_SSL(server, port, context=ssl.create_default_context()) else: tout = xConnectionContext.getValueByName("Timeout") if dbg: |