Skip to content

Commit 7cc2a30

Browse files
authored
Merge pull request ceph#66089 from rhcs-dashboard/secure-alerts-smtp
mgr/alerts: enforce ssl context to SMTP_SSL Reviewed-by: Ernesto Puerta <[email protected]>
2 parents 661e85a + 5f7fc52 commit 7cc2a30

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/pybind/mgr/alerts/module.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from typing import Any, Optional, Dict, List, TYPE_CHECKING, Union
1010
import json
1111
import smtplib
12+
import ssl
1213

1314

1415
class Alerts(MgrModule):
@@ -236,9 +237,10 @@ def _send_alert_smtp(self,
236237

237238
# send
238239
try:
240+
context = ssl.create_default_context()
239241
if self.smtp_ssl:
240242
server: Union[smtplib.SMTP_SSL, smtplib.SMTP] = \
241-
smtplib.SMTP_SSL(self.smtp_host, self.smtp_port)
243+
smtplib.SMTP_SSL(self.smtp_host, self.smtp_port, context=context)
242244
else:
243245
server = smtplib.SMTP(self.smtp_host, self.smtp_port)
244246
if self.smtp_password:

0 commit comments

Comments
 (0)