From a55af2ed5db46e99318e2a3b18d6ae0e33f83707 Mon Sep 17 00:00:00 2001 From: markesha <> Date: Fri, 15 Nov 2024 14:16:40 +0100 Subject: [PATCH] Fix #1469 Use a different checksum calculation method to run in FIPS env Python 3.10 and later versions rely on OpenSSL 1.1.1 or newer, which includes FIPS-compliance checks. MD5 is not an approved algorithm in FIPS mode, so attempting to instantiate self.blob.download_to_file(self._file) will fail when the system is running in FIPS mode. The change configures the `download_to_file` function to use an alternative algorithm provided by gcloud storage SDK - 'crc32c' - for checksum calculation. --- storages/backends/gcloud.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storages/backends/gcloud.py b/storages/backends/gcloud.py index 5ae74a1a..e9855752 100644 --- a/storages/backends/gcloud.py +++ b/storages/backends/gcloud.py @@ -62,7 +62,7 @@ def _get_file(self): ) if "r" in self._mode: self._is_dirty = False - self.blob.download_to_file(self._file) + self.blob.download_to_file(self._file, checksum="crc32c") self._file.seek(0) if self._storage.gzip and self.blob.content_encoding == "gzip": self._file = self._decompress_file(mode=self._mode, file=self._file)