uwsgi + django:不支持的哈希类型

时间:2018-10-31 12:00:01

标签: python django openssl uwsgi ubuntu-18.04

当我将django站点部署到Ubuntu 18.04 Server时,我发现使用python manage.py runserver效果很好。但是当我使用uwsgi运行此django站点时,unsupported hash type错误始终出现在提交我的登录表单。

环境:Ubuntu 18.04 / anaconda3(使用conda管理virtualenvs)/python3.6/uwsgi2.0.17/django2.0 /

错误详细信息:这是异常来自何处:user = authenticate(username=username, password=password)

异常类型:ValueError 异常值:
不支持的哈希类型

我的uwsgi ini文件:

[uwsgi]
chdir = /www/wwwroot/django-xxx/
plungins = python,gevent
socket = 127.0.0.1:8080
module = apps.wsgi:application
gevent-early-monkey-patch = True
gevent-wait-for-hub = True
gevent = 10
workers = 3
master = True
vacuum = True
user = root
logto = /www/wwwroot/django-xxx/uwsgi.log

跟踪:

File "/anaconda3/envs/django-sspanel-7/lib/python3.7/site-packages/django/core/handlers/exception.py" in inner
  35.             response = get_response(request)

File "/anaconda3/envs/django-sspanel-7/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response
  128.                 response = self.process_exception_by_middleware(e, request)

File "/anaconda3/envs/django-sspanel-7/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response
  126.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "./apps/sspanel/views.py" in user_login
  94.             user = authenticate(username=username, password=password)

File "/anaconda3/envs/django-sspanel-7/lib/python3.7/site-packages/django/contrib/auth/__init__.py" in authenticate
  70.             user = _authenticate_with_backend(backend, backend_path, request, credentials)

File "/anaconda3/envs/django-sspanel-7/lib/python3.7/site-packages/django/contrib/auth/__init__.py" in _authenticate_with_backend
  115.     return backend.authenticate(*args, **credentials)

File "/anaconda3/envs/django-sspanel-7/lib/python3.7/site-packages/django/contrib/auth/backends.py" in authenticate
  22.             if user.check_password(password) and self.user_can_authenticate(user):

File "/anaconda3/envs/django-sspanel-7/lib/python3.7/site-packages/django/contrib/auth/base_user.py" in check_password
  111.         return check_password(raw_password, self.password, setter)

File "/anaconda3/envs/django-sspanel-7/lib/python3.7/site-packages/django/contrib/auth/hashers.py" in check_password
  50.     is_correct = hasher.verify(password, encoded)

File "/anaconda3/envs/django-sspanel-7/lib/python3.7/site-packages/django/contrib/auth/hashers.py" in verify
  256.         encoded_2 = self.encode(password, salt, int(iterations))

File "/anaconda3/envs/django-sspanel-7/lib/python3.7/site-packages/django/contrib/auth/hashers.py" in encode
  249.         hash = pbkdf2(password, salt, iterations, digest=self.digest)

File "/anaconda3/envs/django-sspanel-7/lib/python3.7/site-packages/django/utils/crypto.py" in pbkdf2
  85.     return hashlib.pbkdf2_hmac(digest().name, password, salt, iterations, dklen)

更新:我的进一步探索 1.更改为ubuntu 16.04,无任何其他更改,不起作用; 2.更改安装uwsgi的方式,已解决问题:安装uwsgi的原始方法是安装gcc 4.7并使用它来安装uwsgi(如果直接安装uwsgi,则安装会失败,因为根据我的google结果,gcc版本过高)。我尝试用conda安装uwsgi,最后这个问题消失了。

0 个答案:

没有答案