diff options
author | Brian Rosmaita <rosmaita.fossdev@gmail.com> | 2020-04-07 00:13:49 -0400 |
---|---|---|
committer | Brian Rosmaita <rosmaita.fossdev@gmail.com> | 2020-05-04 08:56:58 -0400 |
commit | 56186d6d5aa1a0c8fde99eeb535a650b0495925d (patch) | |
tree | e94280deebebcc70ee69bd050466a42937d47a99 /glanceclient/common | |
parent | cf5434a1b886b152781a206815adff176d2e67fd (diff) | |
download | python-glanceclient-56186d6d5aa1a0c8fde99eeb535a650b0495925d.tar.gz |
Fail gracefully when MD5 is unavailable
The glanceclient currently assumes that MD5 will always be available.
This is not the case, however, in a FIPS-compliant environment. This
patch enables the glanceclient to fail gracefully in such a case.
Closes-bug: #1871675
Change-Id: Ibd89989e06cc5be7da71f5f21561d73b5abc4104
Diffstat (limited to 'glanceclient/common')
-rw-r--r-- | glanceclient/common/utils.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/glanceclient/common/utils.py b/glanceclient/common/utils.py index bc0c0eb..0fde763 100644 --- a/glanceclient/common/utils.py +++ b/glanceclient/common/utils.py @@ -436,7 +436,14 @@ def integrity_iter(iter, checksum): :raises: IOError """ - md5sum = hashlib.md5() + try: + md5sum = hashlib.new('md5') + except ValueError: + raise IOError(errno.EPIPE, + 'Corrupt image download. Expected checksum is %s ' + 'but md5 algorithm is not available on the client' % + checksum) + for chunk in iter: yield chunk if isinstance(chunk, six.string_types): |