Skip to content

Commit

Permalink
Add email backend that behaves like in Django 3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
hmpf committed Feb 27, 2024
1 parent 3b09e9b commit b6c145d
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/argus/workarounds.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import ssl

from django.core.mail.backends.smtp import EmailBackend as SMTPBackend
from django.utils.functional import cached_property


__all__ = ["OldStyleEmailBackend"]


class OldStyleEmailBackend(SMTPBackend):
@cached_property
def ssl_context(self):
if self.ssl_certfile or self.ssl_keyfile:
ssl_context = ssl.SSLContext(protocol=ssl.PROTOCOL_TLS_CLIENT)
ssl_context.load_cert_chain(self.ssl_certfile, self.ssl_keyfile)
return ssl_context
else:
ssl_context = ssl.create_default_context()

Check failure

Code scanning / SonarCloud

Server hostnames should be verified during SSL/TLS connections High

Enable server hostname verification on this SSL/TLS connection. See more on SonarCloud
ssl_context.check_hostname = False
ssl_context.verify_mode = ssl.CERT_NONE

Check failure

Code scanning / SonarCloud

Server certificates should be verified during SSL/TLS connections High

Enable server certificate validation on this SSL/TLS connection. See more on SonarCloud
return ssl_context

0 comments on commit b6c145d

Please sign in to comment.