flask-caching icon indicating copy to clipboard operation
flask-caching copied to clipboard

md5 hash_method in filesystemcache.py results in errors when FIPS mode is enabled on CentOS

Open rmotapar opened this issue 4 years ago • 0 comments

When using this module in a FIPS enabled CentOS environment, we are seeing the below error. This is expected because md5 hash method is not FIPs compliant.

File "/home/rammy/.local/lib/python3.6/site-packages/flask_caching/backends/init.py", line 68, in filesystem return FileSystemCache(*args, **kwargs) File "/home/rammy/.local/lib/python3.6/site-packages/flask_caching/backends/filesystemcache.py", line 80, in init self._update_count(value=len(self._list_dir())) File "/home/rammy/.local/lib/python3.6/site-packages/flask_caching/backends/filesystemcache.py", line 108, in _list_dir for name in (self._fs_count_file,) File "/home/rammy/.local/lib/python3.6/site-packages/flask_caching/backends/filesystemcache.py", line 108, in for name in (self._fs_count_file,) File "/home/rammy/.local/lib/python3.6/site-packages/flask_caching/backends/filesystemcache.py", line 149, in _get_filename hash = self._hash_method(key).hexdigest() ValueError: error:060800A3:digital envelope routines:EVP_DigestInit_ex:disabled for fips

To get rid of the error, we had to replace

hash_method=hashlib.md5

with

hash_method=hashlib.sha256

in filesystemcache.py. Not sure if this would break anything else but it did work for our use case. We would really appreciate if this change can be made official.

Thanks!

rmotapar avatar Jan 07 '21 20:01 rmotapar