scripting/source/pyprov/mailmerge.py |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

New commits:
commit d1eb76559cb127700de0b9b7efef7394dfb4020d
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Fri Jul 28 12:13:41 2023 +0100
Commit:     Thorsten Behrens <thorsten.behr...@allotropia.de>
CommitDate: Sat Sep 9 23:47:13 2023 +0200

    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.behr...@allotropia.de>
    (cherry picked from commit e3d28846c2343072750197fcdeaf44a945ddcb61)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156734
    Tested-by: Thorsten Behrens <thorsten.behr...@allotropia.de>

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:

Reply via email to