sslobj.do_handshake failure and "error: [Errno 0] Error"
sslobj.do_handshake failure and "error: [Errno 0] Error"
我在 Ubuntu 14.04
上有一个 Django 应用 运行
当我使用 requests 模块或 smtp 模块并尝试建立加密连接时,我经常(不总是,主要是每隔一段时间)收到此错误:
错误:[Errno 0] 错误
长错误(此处来自发送邮件):
mod_wsgi (pid=17021): Exception occurred processing WSGI script '/var/www/primomedico/primomedico/wsgi.py'.
[Fri Jul 01 15:11:11.432392 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] Traceback (most recent call last):
[Fri Jul 01 15:11:11.432416 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] File "/var/virtualenv/primo/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 189, in __call__
[Fri Jul 01 15:11:11.432459 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] response = self.get_response(request)
[Fri Jul 01 15:11:11.432473 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] File "/var/virtualenv/primo/lib/python2.7/site-packages/django/core/handlers/base.py", line 218, in get_response
[Fri Jul 01 15:11:11.432496 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
[Fri Jul 01 15:11:11.432509 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] File "/var/virtualenv/primo/lib/python2.7/site-packages/django/core/handlers/base.py", line 256, in handle_uncaught_exception
[Fri Jul 01 15:11:11.432529 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] 'request': request
[Fri Jul 01 15:11:11.432542 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] File "/usr/lib/python2.7/logging/__init__.py", line 1178, in error
[Fri Jul 01 15:11:11.432564 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] self._log(ERROR, msg, args, **kwargs)
[Fri Jul 01 15:11:11.432576 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] File "/usr/lib/python2.7/logging/__init__.py", line 1271, in _log
[Fri Jul 01 15:11:11.432595 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] self.handle(record)
[Fri Jul 01 15:11:11.432606 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] File "/usr/lib/python2.7/logging/__init__.py", line 1281, in handle
[Fri Jul 01 15:11:11.432625 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] self.callHandlers(record)
[Fri Jul 01 15:11:11.432637 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] File "/usr/lib/python2.7/logging/__init__.py", line 1321, in callHandlers
[Fri Jul 01 15:11:11.432655 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] hdlr.handle(record)
[Fri Jul 01 15:11:11.432666 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] File "/usr/lib/python2.7/logging/__init__.py", line 749, in handle
[Fri Jul 01 15:11:11.432684 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] self.emit(record)
[Fri Jul 01 15:11:11.432697 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] File "/var/virtualenv/primo/lib/python2.7/site-packages/django/utils/log.py", line 129, in emit
[Fri Jul 01 15:11:11.432718 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] self.send_mail(subject, message, fail_silently=True, html_message=html_message)
[Fri Jul 01 15:11:11.432747 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] File "/var/virtualenv/primo/lib/python2.7/site-packages/django/utils/log.py", line 132, in send_mail
[Fri Jul 01 15:11:11.432767 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] mail.mail_admins(subject, message, *args, connection=self.connection(), **kwargs)
[Fri Jul 01 15:11:11.432781 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] File "/var/virtualenv/primo/lib/python2.7/site-packages/django/core/mail/__init__.py", line 98, in mail_admins
[Fri Jul 01 15:11:11.432802 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] mail.send(fail_silently=fail_silently)
[Fri Jul 01 15:11:11.432813 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] File "/var/virtualenv/primo/lib/python2.7/site-packages/django/core/mail/message.py", line 303, in send
[Fri Jul 01 15:11:11.432845 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] return self.get_connection(fail_silently).send_messages([self])
[Fri Jul 01 15:11:11.432858 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] File "/var/virtualenv/primo/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 100, in send_messages
[Fri Jul 01 15:11:11.432878 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] new_conn_created = self.open()
[Fri Jul 01 15:11:11.432890 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] File "/var/virtualenv/primo/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 64, in open
[Fri Jul 01 15:11:11.432908 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] self.connection.starttls(keyfile=self.ssl_keyfile, certfile=self.ssl_certfile)
[Fri Jul 01 15:11:11.432919 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] File "/usr/lib/python2.7/smtplib.py", line 649, in starttls
[Fri Jul 01 15:11:11.432937 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] self.sock = ssl.wrap_socket(self.sock, keyfile, certfile)
[Fri Jul 01 15:11:11.432948 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] File "/usr/lib/python2.7/ssl.py", line 487, in wrap_socket
[Fri Jul 01 15:11:11.432965 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] ciphers=ciphers)
[Fri Jul 01 15:11:11.432976 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] File "/usr/lib/python2.7/ssl.py", line 243, in __init__
[Fri Jul 01 15:11:11.432992 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] self.do_handshake()
[Fri Jul 01 15:11:11.433003 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] File "/usr/lib/python2.7/ssl.py", line 405, in do_handshake
[Fri Jul 01 15:11:11.433020 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] self._sslobj.do_handshake()
[Fri Jul 01 15:11:11.433042 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] error: [Errno 0] Error
我不知道在这里做什么。我在 Ubuntu 上安装了 openssl 并作为 python 软件包。它是最新的。
我需要手动生成证书吗?
此问题是否与其他问题有关?
这就是我配置电子邮件的方式:
EMAIL_USE_TLS = True
#EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.dd24.net'
EMAIL_HOST_PASSWORD = 'abcdef'
EMAIL_HOST_USER = 'bp@example.com'
EMAIL_PORT = 587
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
感谢任何帮助。
经过长时间的研究,我发现它是密码模块中的一个错误。
参见:
https://github.com/pyca/cryptography/issues/2299
解决方法:
地方
WSGIApplicationGroup %{GLOBAL}
在 apache 虚拟主机配置中
例如
<Directory /var/www/path/to/wsgi>
<Files wsgi.py>
Require all granted
</Files>
WSGIApplicationGroup %{GLOBAL}
</Directory>
我在 Ubuntu 14.04
上有一个 Django 应用 运行当我使用 requests 模块或 smtp 模块并尝试建立加密连接时,我经常(不总是,主要是每隔一段时间)收到此错误:
错误:[Errno 0] 错误
长错误(此处来自发送邮件):
mod_wsgi (pid=17021): Exception occurred processing WSGI script '/var/www/primomedico/primomedico/wsgi.py'.
[Fri Jul 01 15:11:11.432392 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] Traceback (most recent call last):
[Fri Jul 01 15:11:11.432416 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] File "/var/virtualenv/primo/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 189, in __call__
[Fri Jul 01 15:11:11.432459 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] response = self.get_response(request)
[Fri Jul 01 15:11:11.432473 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] File "/var/virtualenv/primo/lib/python2.7/site-packages/django/core/handlers/base.py", line 218, in get_response
[Fri Jul 01 15:11:11.432496 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
[Fri Jul 01 15:11:11.432509 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] File "/var/virtualenv/primo/lib/python2.7/site-packages/django/core/handlers/base.py", line 256, in handle_uncaught_exception
[Fri Jul 01 15:11:11.432529 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] 'request': request
[Fri Jul 01 15:11:11.432542 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] File "/usr/lib/python2.7/logging/__init__.py", line 1178, in error
[Fri Jul 01 15:11:11.432564 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] self._log(ERROR, msg, args, **kwargs)
[Fri Jul 01 15:11:11.432576 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] File "/usr/lib/python2.7/logging/__init__.py", line 1271, in _log
[Fri Jul 01 15:11:11.432595 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] self.handle(record)
[Fri Jul 01 15:11:11.432606 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] File "/usr/lib/python2.7/logging/__init__.py", line 1281, in handle
[Fri Jul 01 15:11:11.432625 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] self.callHandlers(record)
[Fri Jul 01 15:11:11.432637 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] File "/usr/lib/python2.7/logging/__init__.py", line 1321, in callHandlers
[Fri Jul 01 15:11:11.432655 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] hdlr.handle(record)
[Fri Jul 01 15:11:11.432666 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] File "/usr/lib/python2.7/logging/__init__.py", line 749, in handle
[Fri Jul 01 15:11:11.432684 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] self.emit(record)
[Fri Jul 01 15:11:11.432697 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] File "/var/virtualenv/primo/lib/python2.7/site-packages/django/utils/log.py", line 129, in emit
[Fri Jul 01 15:11:11.432718 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] self.send_mail(subject, message, fail_silently=True, html_message=html_message)
[Fri Jul 01 15:11:11.432747 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] File "/var/virtualenv/primo/lib/python2.7/site-packages/django/utils/log.py", line 132, in send_mail
[Fri Jul 01 15:11:11.432767 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] mail.mail_admins(subject, message, *args, connection=self.connection(), **kwargs)
[Fri Jul 01 15:11:11.432781 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] File "/var/virtualenv/primo/lib/python2.7/site-packages/django/core/mail/__init__.py", line 98, in mail_admins
[Fri Jul 01 15:11:11.432802 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] mail.send(fail_silently=fail_silently)
[Fri Jul 01 15:11:11.432813 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] File "/var/virtualenv/primo/lib/python2.7/site-packages/django/core/mail/message.py", line 303, in send
[Fri Jul 01 15:11:11.432845 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] return self.get_connection(fail_silently).send_messages([self])
[Fri Jul 01 15:11:11.432858 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] File "/var/virtualenv/primo/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 100, in send_messages
[Fri Jul 01 15:11:11.432878 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] new_conn_created = self.open()
[Fri Jul 01 15:11:11.432890 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] File "/var/virtualenv/primo/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 64, in open
[Fri Jul 01 15:11:11.432908 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] self.connection.starttls(keyfile=self.ssl_keyfile, certfile=self.ssl_certfile)
[Fri Jul 01 15:11:11.432919 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] File "/usr/lib/python2.7/smtplib.py", line 649, in starttls
[Fri Jul 01 15:11:11.432937 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] self.sock = ssl.wrap_socket(self.sock, keyfile, certfile)
[Fri Jul 01 15:11:11.432948 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] File "/usr/lib/python2.7/ssl.py", line 487, in wrap_socket
[Fri Jul 01 15:11:11.432965 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] ciphers=ciphers)
[Fri Jul 01 15:11:11.432976 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] File "/usr/lib/python2.7/ssl.py", line 243, in __init__
[Fri Jul 01 15:11:11.432992 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] self.do_handshake()
[Fri Jul 01 15:11:11.433003 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] File "/usr/lib/python2.7/ssl.py", line 405, in do_handshake
[Fri Jul 01 15:11:11.433020 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] self._sslobj.do_handshake()
[Fri Jul 01 15:11:11.433042 2016] [:error] [pid 17021] [remote 84.189.143.193:9785] error: [Errno 0] Error
我不知道在这里做什么。我在 Ubuntu 上安装了 openssl 并作为 python 软件包。它是最新的。
我需要手动生成证书吗? 此问题是否与其他问题有关?
这就是我配置电子邮件的方式:
EMAIL_USE_TLS = True
#EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.dd24.net'
EMAIL_HOST_PASSWORD = 'abcdef'
EMAIL_HOST_USER = 'bp@example.com'
EMAIL_PORT = 587
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
感谢任何帮助。
经过长时间的研究,我发现它是密码模块中的一个错误。
参见: https://github.com/pyca/cryptography/issues/2299
解决方法: 地方 WSGIApplicationGroup %{GLOBAL}
在 apache 虚拟主机配置中 例如
<Directory /var/www/path/to/wsgi>
<Files wsgi.py>
Require all granted
</Files>
WSGIApplicationGroup %{GLOBAL}
</Directory>