#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.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701910e8b0c58-dc77efbe-7e52-4785-a416-1b87781aedf6-000000%40eu-central-1.amazonses.com.

Reply via email to