diff --git a/CHANGELOG b/CHANGELOG index 9f09589077..bc54c133ea 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Enforce certificate validation for SMTP connection (issue11564) * Use singleton for TableHandler Version 6.4.0 - 2022-05-02 diff --git a/trytond/sendmail.py b/trytond/sendmail.py index b415e6acb5..883c5f48d5 100644 --- a/trytond/sendmail.py +++ b/trytond/sendmail.py @@ -2,6 +2,7 @@ # this repository contains the full copyright notices and license terms. import logging import smtplib +import ssl import time from email.message import Message from email.mime.text import MIMEText @@ -89,6 +90,7 @@ def get_smtp_server(uri=None, strict=False): extra[key] = cast.get(key, lambda a: a)(value[0]) if uri.scheme.startswith('smtps'): connector = smtplib.SMTP_SSL + extra['context'] = ssl.create_default_context() else: connector = smtplib.SMTP try: @@ -100,7 +102,7 @@ def get_smtp_server(uri=None, strict=False): return if 'tls' in uri.scheme: - server.starttls() + server.starttls(context=ssl.create_default_context()) if uri.username and uri.password: server.login(