Skip to content

Commit

Permalink
openssl_* modules: prevent crash on fingerprint determination in FIPS…
Browse files Browse the repository at this point in the history
… mode (ansible#67515)

* openssl_* modules: prevent crash on fingerprint determination in FIPS mode.

* Add changelog.
  • Loading branch information
felixfontein authored Feb 18, 2020
1 parent 9f41d0e commit ca57871
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions changelogs/fragments/67515-openssl-fingerprint-fips.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- "openssl_* modules - prevent crash on fingerprint determination in FIPS mode (https://github.com/ansible/ansible/issues/67213)."
7 changes: 6 additions & 1 deletion lib/ansible/module_utils/crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,12 @@ def get_fingerprint_of_bytes(source):

for algo in algorithms:
f = getattr(hashlib, algo)
h = f(source)
try:
h = f(source)
except ValueError:
# This can happen for hash algorithms not supported in FIPS mode
# (https://github.com/ansible/ansible/issues/67213)
continue
try:
# Certain hash functions have a hexdigest() which expects a length parameter
pubkey_digest = h.hexdigest()
Expand Down

0 comments on commit ca57871

Please sign in to comment.