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

New commits:
commit 4a5c329e22b7ad52a14ca39028e4a645c1bbbe40
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: Fri Jul 28 16:03:34 2023 +0200

    follow python recommendation and pass SSL contexts
    
    i.e. https://docs.python.org/3/library/ssl.html#security-considerations
    
    Change-Id: I67a0f9e1c25abc6644412b014f30933a7e681da2

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:

Reply via email to