Enforce certificate validation for SMTP connection
issue11564 review417381003
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
* Enforce certificate validation for SMTP connection (issue11564)
|
||||
* Use singleton for TableHandler
|
||||
|
||||
Version 6.4.0 - 2022-05-02
|
||||
|
||||
+3
-1
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user