summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolan.mcnamara@collabora.com>2023-07-28 12:13:41 +0100
committerThorsten Behrens <thorsten.behrens@allotropia.de>2023-07-28 16:03:34 +0200
commit4a5c329e22b7ad52a14ca39028e4a645c1bbbe40 (patch)
tree0b1795cfdad75e5275c840125553c60126f04bbc
parentdbb6992156773d0be0ea59b3832516f5f16c1f0c (diff)
follow python recommendation and pass SSL contexts
i.e. https://docs.python.org/3/library/ssl.html#security-considerations Change-Id: I67a0f9e1c25abc6644412b014f30933a7e681da2
-rw-r--r--scripting/source/pyprov/mailmerge.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/scripting/source/pyprov/mailmerge.py b/scripting/source/pyprov/mailmerge.py
index 079744007816..9b0e35ccdf42 100644
--- a/scripting/source/pyprov/mailmerge.py
+++ b/scripting/source/pyprov/mailmerge.py
@@ -49,7 +49,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
@@ -105,7 +105,7 @@ class PyMailSMTPService(unohelper.Base, XSmtpService):
if dbg:
print("Timeout: " + str(tout), file=dbgout)
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)
@@ -121,7 +121,7 @@ class PyMailSMTPService(unohelper.Base, XSmtpService):
print("ConnectionType: " + connectiontype, file=dbgout)
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()
@@ -325,7 +325,7 @@ class PyMailIMAPService(unohelper.Base, XMailService):
print(connectiontype, file=dbgout)
print("BEFORE", file=dbgout)
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=dbgout)
@@ -397,7 +397,7 @@ class PyMailPOP3Service(unohelper.Base, XMailService):
print(connectiontype, file=dbgout)
print("BEFORE", file=dbgout)
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: