#35653: SSL error sending mail
-------------------------+---------------------------------------
Reporter: dkaylor | Type: Bug
Status: new | Component: Core (Mail)
Version: 5.0 | Severity: Normal
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------+---------------------------------------
We have an SMTP server that is not signed by a public CA. Sending email
with no SSL settings results in an "SSL: CERTIFICATE_VERIFY_FAILED" error.
If we set EMAIL_SSL_CERTFILE, we receive the same error. We do not have
access to the key file to test with EMAIL_SSL_KEYFILE. Clients often do
not have access to keys so this shouldn't be required.
Django is loading the cert files with load_cert_chain, but I believe
load_verify_locations would be more appropriate:
https://github.com/django/django/blob/main/django/core/mail/backends/smtp.py#L63
The examples in the Python docs use the former for servers and the latter
for clients:
https://docs.python.org/3/library/ssl.html
I wrote a simple test with load_cert_chain and it fails with the same SSL
error:
{{{
ssl_context.load_cert_chain(cacert)
}}}
If I change to load_verify_locations it works
{{{
ssl_context.load_verify_locations(cacert)
}}}
--
Ticket URL: <
https://code.djangoproject.com/ticket/35653>
Django <
https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.