Opened 21 months ago

Closed 21 months ago

Last modified 19 months ago

#34386 closed Bug (fixed)

Error while sending TLS smtp email when no EMAIL_SSL_CERTFILE / EMAIL_SSL_KEYFILE are specified in project settings

Reported by: Dmitriy Sintsov Owned by: Dmitriy Sintsov
Component: Core (Mail) Version: dev
Severity: Release blocker Keywords: smtp mail backend
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

Reproduced with unpatched Django 4.2b1. Works with unpatched Django 3.2 / 4.1

Here is the traceback with Django 4.2b1:

ERROR Internal Server Error: /password-reset/
Traceback (most recent call last):
  File "/home/user/work/ispdevenv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "/home/user/work/ispdevenv/lib/python3.10/site-packages/django/core/handlers/base.py", line 185, in _get_response
    response = middleware_method(
  File "/home/user/work/ispdevenv/lib/python3.10/site-packages/django_jinja_knockout/middleware.py", line 45, in process_view
    result = self.djk_view(request, view_func, view_args, view_kwargs)
  File "/home/user/work/ispdevenv/lib/python3.10/site-packages/django_jinja_knockout/middleware.py", line 269, in djk_view
    return exception_response(request, e)
  File "/home/user/work/ispdevenv/lib/python3.10/site-packages/django_jinja_knockout/http.py", line 99, in exception_response
    raise e
  File "/home/user/work/ispdevenv/lib/python3.10/site-packages/django_jinja_knockout/middleware.py", line 262, in djk_view
    return view_func(request, *view_args, **view_kwargs)
  File "/home/user/work/ispdevenv/lib/python3.10/site-packages/django/views/generic/base.py", line 104, in view
    return self.dispatch(request, *args, **kwargs)
  File "/home/user/work/ispdevenv/lib/python3.10/site-packages/django/utils/decorators.py", line 46, in _wrapper
    return bound_method(*args, **kwargs)
  File "/home/user/work/ispdevenv/lib/python3.10/site-packages/django/utils/decorators.py", line 134, in _wrapper_view
    response = view_func(request, *args, **kwargs)
  File "/home/user/work/ispdevenv/lib/python3.10/site-packages/django/contrib/auth/views.py", line 242, in dispatch
    return super().dispatch(*args, **kwargs)
  File "/home/user/work/ispdevenv/lib/python3.10/site-packages/django/views/generic/base.py", line 143, in dispatch
    return handler(request, *args, **kwargs)
  File "/home/user/work/ispdevenv/lib/python3.10/site-packages/django/views/generic/edit.py", line 153, in post
    return self.form_valid(form)
  File "/home/user/work/ispdevenv/lib/python3.10/site-packages/django/contrib/auth/views.py", line 255, in form_valid
    form.save(**opts)
  File "/home/user/work/ispdevenv/lib/python3.10/site-packages/django/contrib/auth/forms.py", line 362, in save
    self.send_mail(
  File "/home/user/work/ispdevenv/lib/python3.10/site-packages/django/contrib/auth/forms.py", line 303, in send_mail
    email_message.send()
  File "/home/user/work/ispdevenv/lib/python3.10/site-packages/django/core/mail/message.py", line 298, in send
    return self.get_connection(fail_silently).send_messages([self])
  File "/home/user/work/ispdevenv/lib/python3.10/site-packages/django/core/mail/backends/smtp.py", line 125, in send_messages
    new_conn_created = self.open()
  File "/home/user/work/ispdevenv/lib/python3.10/site-packages/django/core/mail/backends/smtp.py", line 90, in open
    self.connection.starttls(context=self.ssl_context)
  File "/usr/lib/python3.10/smtplib.py", line 790, in starttls
    self.sock = context.wrap_socket(self.sock,
  File "/usr/lib/python3.10/ssl.py", line 513, in wrap_socket
    return self.sslsocket_class._create(
  File "/usr/lib/python3.10/ssl.py", line 1071, in _create
    self.do_handshake()
  File "/usr/lib/python3.10/ssl.py", line 1342, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)
ERROR "POST /password-reset/ HTTP/1.1" 500 194468

Change History (7)

comment:2 by Dmitriy Sintsov, 21 months ago

user@h67:~/work/django/django/core/mail/backends$ git push origin ticket_34386
error: src refspec ticket_34386 does not match any
error: failed to push some refs to 'https://github.com/Dmitri-Sintsov/django.git'

comment:3 by Claude Paroz, 21 months ago

Component: Core (Other)Core (Mail)
Needs tests: set
Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted

comment:4 by Mariusz Felisiak, 21 months ago

Needs tests: unset
Owner: changed from nobody to Dmitriy Sintsov
Status: newassigned
Triage Stage: AcceptedReady for checkin

comment:5 by Mariusz Felisiak <felisiak.mariusz@…>, 21 months ago

Resolution: fixed
Status: assignedclosed

In c914d6c:

Fixed #34386 -- Made SMTP backend load default system root CA certificates by default.

Regression in 2848e5d0ce5cf3c31fe87525536093b21d570f69.

comment:6 by Mariusz Felisiak <felisiak.mariusz@…>, 21 months ago

In b9d89d7:

[4.2.x] Fixed #34386 -- Made SMTP backend load default system root CA certificates by default.

Regression in 2848e5d0ce5cf3c31fe87525536093b21d570f69.

Backport of c914d6cff176ae6bfab2f33a84bcfd45208f1894 from main

comment:7 by David Sanders, 19 months ago

Summary: Error while sending TLS smtp email when no EMAIL_SSL_CERTFILE / EMAIL_SSL_KEYFILE are speficied in project settingsError while sending TLS smtp email when no EMAIL_SSL_CERTFILE / EMAIL_SSL_KEYFILE are specified in project settings
Note: See TracTickets for help on using tickets.
Back to Top