mirror of https://github.com/fail2ban/fail2ban
filter.py: easy-fix to use sha1 instead of md5 if its usage prohibited by some systems following strict standards (like FIPS)
closes gh-1540pull/1551/head
parent
fad953ade6
commit
1071db2256
|
@ -742,7 +742,12 @@ class FileFilter(Filter):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import hashlib
|
import hashlib
|
||||||
|
try:
|
||||||
md5sum = hashlib.md5
|
md5sum = hashlib.md5
|
||||||
|
# try to use it (several standards like FIPS forbid it):
|
||||||
|
md5sum(' ').hexdigest()
|
||||||
|
except: # pragma: no cover
|
||||||
|
md5sum = hashlib.sha1
|
||||||
except ImportError: # pragma: no cover
|
except ImportError: # pragma: no cover
|
||||||
# hashlib was introduced in Python 2.5. For compatibility with those
|
# hashlib was introduced in Python 2.5. For compatibility with those
|
||||||
# elderly Pythons, import from md5
|
# elderly Pythons, import from md5
|
||||||
|
|
Loading…
Reference in New Issue