From 4e28c0b839171ffddc8cbb43e0909adcd25f7e75 Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Mon, 17 Apr 2017 15:34:36 -0400 Subject: [PATCH] Use uuid5() as an option in generate_oid if uuid3 fails. uuid3() uses md5, which is disallowed on systems running in FIPS mode, and will cause a traceback if called. (http://csrc.nist.gov/groups/STM/cavp/validation.html) --- kombu/common.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/kombu/common.py b/kombu/common.py index 58d99152..47d2a59d 100644 --- a/kombu/common.py +++ b/kombu/common.py @@ -9,7 +9,7 @@ from collections import deque from contextlib import contextmanager from functools import partial from itertools import count -from uuid import uuid4, uuid3, NAMESPACE_OID +from uuid import uuid5, uuid4, uuid3, NAMESPACE_OID from amqp import RecoverableConnectionError @@ -50,7 +50,11 @@ def get_node_id(): def generate_oid(node_id, process_id, thread_id, instance): ent = bytes_if_py2('%x-%x-%x-%x' % ( node_id, process_id, thread_id, id(instance))) - return str(uuid3(NAMESPACE_OID, ent)) + try: + ret = str(uuid3(NAMESPACE_OID, ent)) + except ValueError: + ret = str(uuid5(NAMESPACE_OID, ent)) + return ret def oid_from(instance, threads=True):