Django Ubuntu 16.04"不支持的哈希类型"

时间:2018-01-24 06:23:40

标签: python django ubuntu-16.04 hashlib

我已将Web应用程序部署到Ubuntu 16.04 VM。我通过书籍实现了标准的Django登录。一切都在我的生产环境(OS X)上正常运行;但是,当我尝试登录时收到错误

  

ExceptionValue:不支持的哈希类型

Ubuntu is running python 3.5.2

OS X is running python 3.6.1

两者都在运行Django版本1.11.6

我的要求.txt

blessings==1.6
bpython==0.16
certifi==2017.7.27.1
chardet==3.0.4
curtsies==0.2.11
Django==1.11.6
django-extensions==1.9.6
geopy==1.11.0
greenlet==0.4.12
idna==2.6
psycopg2==2.7.3.2
Pygments==2.2.0
pytz==2017.2
requests==2.18.4
six==1.11.0
urllib3==1.22
wcwidth==0.1.7

我正在使用虚拟环境来运行此项目。

回溯路径如下,

回溯:

  

文件   " /home/user_name/proj_folder/my_venv/lib/python3.5/site-packages/django/core/handlers/exception.py"   在内心     41. response = get_response(request)

     

文件   " /home/user_name/proj_folder/my_venv/lib/python3.5/site-packages/django/core/handlers/base.py"   在_get_response中     187. response = self.process_exception_by_middleware(e,request)

     

文件   " /home/user_name/proj_folder/my_venv/lib/python3.5/site-packages/django/core/handlers/base.py"   在_get_response中     185. response = wrapped_callback(request,* callback_args,** callback_kwargs)

     

文件   " /home/user_name/proj_folder/my_venv/lib/python3.5/site-packages/django/contrib/auth/views.py"   在内心     54. return func(* args,** kwargs)

     

文件   " /home/user_name/proj_folder/my_venv/lib/python3.5/site-packages/django/contrib/auth/views.py"   在登录     150.)(请求)

     

文件   " /home/user_name/proj_folder/my_venv/lib/python3.5/site-packages/django/views/generic/base.py"   在视野中     68.返回self.dispatch(request,* args,** kwargs)

     

文件   " /home/user_name/proj_folder/my_venv/lib/python3.5/site-packages/django/utils/decorators.py"   在_wrapper中     67. return bound_func(* args,** kwargs)

     

文件   " /home/user_name/proj_folder/my_venv/lib/python3.5/site-packages/django/views/decorators/debug.py"   在sensitive_post_parameters_wrapper中     76.返回视图(请求,* args,** kwargs)

     

文件   " /home/user_name/proj_folder/my_venv/lib/python3.5/site-packages/django/utils/decorators.py"   在bound_func中     63. return func。 get (self,type(self))(* args2,** kwargs2)

     

文件   " /home/user_name/proj_folder/my_venv/lib/python3.5/site-packages/django/utils/decorators.py"   在_wrapper中     67. return bound_func(* args,** kwargs)

     

文件   " /home/user_name/proj_folder/my_venv/lib/python3.5/site-packages/django/utils/decorators.py"   在_wrapped_view中     149. response = view_func(request,* args,** kwargs)

     

文件   " /home/user_name/proj_folder/my_venv/lib/python3.5/site-packages/django/utils/decorators.py"   在bound_func中     63. return func。 get (self,type(self))(* args2,** kwargs2)

     

文件   " /home/user_name/proj_folder/my_venv/lib/python3.5/site-packages/django/utils/decorators.py"   在_wrapper中     67. return bound_func(* args,** kwargs)

     

文件   " /home/user_name/proj_folder/my_venv/lib/python3.5/site-packages/django/views/decorators/cache.py"   在_wrapped_view_func中     57. response = view_func(request,* args,** kwargs)

     

文件   " /home/user_name/proj_folder/my_venv/lib/python3.5/site-packages/django/utils/decorators.py"   在bound_func中     63. return func。 get (self,type(self))(* args2,** kwargs2)

     

文件   " /home/user_name/proj_folder/my_venv/lib/python3.5/site-packages/django/contrib/auth/views.py"   在发货     90. return super(LoginView,self).dispatch(request,* args,** kwargs)

     

文件   " /home/user_name/proj_folder/my_venv/lib/python3.5/site-packages/django/views/generic/base.py"   在发货     88.返回处理程序(request,* args,** kwargs)

     

文件   " /home/user_name/proj_folder/my_venv/lib/python3.5/site-packages/django/views/generic/edit.py"   在邮寄     182.如果是form.is_valid():

     

文件   " /home/user_name/proj_folder/my_venv/lib/python3.5/site-packages/django/forms/forms.py"   在is_valid     183.返回self.is_bound而不是self.errors

     

文件   " /home/user_name/proj_folder/my_venv/lib/python3.5/site-packages/django/forms/forms.py"   在错误     175. self.full_clean()

     

文件   " /home/user_name/proj_folder/my_venv/lib/python3.5/site-packages/django/forms/forms.py"   在full_clean     385. self._clean_form()

     

文件   " /home/user_name/proj_folder/my_venv/lib/python3.5/site-packages/django/forms/forms.py"   在_clean_form中     412. cleaning_data = self.clean()

     

文件   " /home/user_name/proj_folder/my_venv/lib/python3.5/site-packages/django/contrib/auth/forms.py"   在干净     187. self.user_cache = authenticate(self.request,username = username,password = password)

     

文件   " /home/user_name/proj_folder/my_venv/lib/python3.5/site-packages/django/contrib/auth/的初始化的.py"   在认证     70. user = _authenticate_with_backend(backend,backend_path,request,credentials)

     

文件   " /home/user_name/proj_folder/my_venv/lib/python3.5/site-packages/django/contrib/auth/的初始化的.py"   在_authenticate_with_backend中     115. return backend.authenticate(* args,** credentials)

     

文件   " /home/user_name/proj_folder/my_venv/lib/python3.5/site-packages/django/contrib/auth/backends.py"   在认证     24.如果user.check_password(密码)和self.user_can_authenticate(用户):

     

文件   " /home/user_name/proj_folder/my_venv/lib/python3.5/site-packages/django/contrib/auth/base_user.py"   在check_password中     118. return check_password(raw_password,self.password,setter)

     

文件   " /home/user_name/proj_folder/my_venv/lib/python3.5/site-packages/django/contrib/auth/hashers.py"   在check_password中     52. is_correct = hasher.verify(密码,编码)

     

文件   " /home/user_name/proj_folder/my_venv/lib/python3.5/site-packages/django/contrib/auth/hashers.py"   在验证     265. encoded_2 = self.encode(密码,盐,int(迭代))

     

文件   " /home/user_name/proj_folder/my_venv/lib/python3.5/site-packages/django/contrib/auth/hashers.py"   在编码     258. hash = pbkdf2(password,salt,iterations,digest = self.digest)

     

文件   " /home/user_name/proj_folder/my_venv/lib/python3.5/site-packages/django/utils/crypto.py"   在pbkdf2中     140. digest()。name,password,salt,iterations,dklen)

     

异常类型:ValueError at / login / Exception Value:unsupported   哈希类型

回溯完全在我的venv文件夹中。最终错误如下所示。

的第133-146行
  

/home/user_name/proj_folder/my_env/lib/python3.5/site-packages/django/utils/crypto.py   在pbkdf2

        if digest is None:
            digest = hashlib.sha256
        if not dklen:
            dklen = None
        password = force_bytes(password)
        salt = force_bytes(salt)
        return hashlib.pbkdf2_hmac(
            digest().name, password, salt, iterations, dklen) ...
else:
    def pbkdf2(password, salt, iterations, dklen=0, digest=None):
        """
        Implements PBKDF2 as defined in RFC 2898, section 5.2
        HMAC+SHA256 is used as the default pseudo random function.

最后一个例外是digest().name, password, salt, iterations, dklen)

使用Local Vars:

digest      <built-in function openssl_sha256>
dklen       None
iterations  36000
password    b'mypassword'
salt        b'saltshownhere'

我已经看到了与Solaris 10相关的类似问题,其中可能存在SSL安装/版本问题。两台机器上都安装了OpenSSL。虽然它们是不同的版本。

Ubuntu - OpenSSL 1.0.2g

OS - OpenSSL 0.9.8zh

我可以通过删除登录要求来成功运行我的应用程序。我想更好地了解这里发生的事情。这可能是我的开发和生产环境之间由python或OpenSSL引起的版本错误吗?

0 个答案:

没有答案