From 82051925bc2e27c2f48536def9c035df954c7c73 Mon Sep 17 00:00:00 2001 From: Matthew Vine <32849887+MattTheCuber@users.noreply.github.com> Date: Tue, 23 Apr 2024 08:45:02 -0400 Subject: [PATCH 1/2] fix(apps): fix download fails on FIPS machines Signed-off-by: Matthew Vine <32849887+MattTheCuber@users.noreply.github.com> --- monai/apps/utils.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/monai/apps/utils.py b/monai/apps/utils.py index db541923b5..385a9fb6a4 100644 --- a/monai/apps/utils.py +++ b/monai/apps/utils.py @@ -135,7 +135,12 @@ def check_hash(filepath: PathLike, val: str | None = None, hash_type: str = "md5 logger.info(f"Expected {hash_type} is None, skip {hash_type} check for file {filepath}.") return True actual_hash_func = look_up_option(hash_type.lower(), SUPPORTED_HASH_TYPES) - actual_hash = actual_hash_func() + + if sys.version_info >= (3, 9): + actual_hash = actual_hash_func(usedforsecurity=False) + else: + actual_hash = actual_hash_func() + try: with open(filepath, "rb") as f: for chunk in iter(lambda: f.read(1024 * 1024), b""): From 6dd0b824b75f5404f40ad5dcbb4f266f71261a54 Mon Sep 17 00:00:00 2001 From: Matthew Vine <32849887+MattTheCuber@users.noreply.github.com> Date: Tue, 23 Apr 2024 12:53:54 -0400 Subject: [PATCH 2/2] docs(apps): add hash change comment Co-authored-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Signed-off-by: Matthew Vine <32849887+MattTheCuber@users.noreply.github.com> --- monai/apps/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monai/apps/utils.py b/monai/apps/utils.py index 385a9fb6a4..0c998146a3 100644 --- a/monai/apps/utils.py +++ b/monai/apps/utils.py @@ -137,7 +137,7 @@ def check_hash(filepath: PathLike, val: str | None = None, hash_type: str = "md5 actual_hash_func = look_up_option(hash_type.lower(), SUPPORTED_HASH_TYPES) if sys.version_info >= (3, 9): - actual_hash = actual_hash_func(usedforsecurity=False) + actual_hash = actual_hash_func(usedforsecurity=False) # allows checks on FIPS enabled machines else: actual_hash = actual_hash_func()