From 1d61098dee6c1d60741a7840b8b9d1af4b1ab770 Mon Sep 17 00:00:00 2001 From: FrantiĊĦek Zatloukal Date: Feb 02 2021 11:14:42 +0000 Subject: Mailing: allow to use insecure certificates --- diff --git a/conf/settings.py.example b/conf/settings.py.example index 464f7cc..6433bcf 100644 --- a/conf/settings.py.example +++ b/conf/settings.py.example @@ -90,6 +90,8 @@ TASKS_ROT_AFTER = 7200 # FAILURE EMAILS # To receive failres via email, you need to set up smtp connection details and set SEND_ERROR_EMAILS to True SEND_ERROR_EMAILS = False +# True = skip smtp certificate verification / False = require valid smtp certificate +SMTP_INSECURE_CERTS = True SMTP_SERVER = "" SMTP_PORT = 465 SMTP_LOGIN = "" diff --git a/oraculum/config.py b/oraculum/config.py index 1af0ee0..ccf355f 100644 --- a/oraculum/config.py +++ b/oraculum/config.py @@ -117,6 +117,8 @@ class Config(object): # FAILURE EMAILS # To receive failres via email, you need to set up smtp connection details and set SEND_ERROR_EMAILS to True SEND_ERROR_EMAILS = False + # True = skip smtp certificate verification / False = require valid smtp certificate + SMTP_INSECURE_CERTS = True SMTP_SERVER = "" SMTP_PORT = 465 SMTP_LOGIN = "" diff --git a/oraculum/utils/mailing_utils.py b/oraculum/utils/mailing_utils.py index 930762d..96cc054 100644 --- a/oraculum/utils/mailing_utils.py +++ b/oraculum/utils/mailing_utils.py @@ -34,8 +34,12 @@ def send_mail(message): msg['Subject'] = 'STG Oraculum Failures' msg.add_header('Content-Type','text/html') msg.set_payload(message) - # Create a secure SSL context - context = ssl.create_default_context() + if app.config["SMTP_INSECURE_CERTS"]: + # Create an insecure SSL context + context = ssl._create_unverified_context() + else: + # Create a secure SSL context + context = ssl.create_default_context() with smtplib.SMTP(app.config["SMTP_SERVER"], app.config["SMTP_PORT"]) as server: server.ehlo() # Can be omitted server.starttls(context=context)