Enforce certificate validation for SMTP connection

issue11564
review417381003
This commit is contained in:
Cédric Krier
2022-06-21 10:16:35 +02:00
parent 16275e0259
commit 53227fcf7b
2 changed files with 4 additions and 1 deletions
+1
View File
@@ -1,3 +1,4 @@
* Enforce certificate validation for SMTP connection (issue11564)
* Use singleton for TableHandler
Version 6.4.0 - 2022-05-02
+3 -1
View File
@@ -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(