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)
This commit is contained in:
Bill Nottingham 2017-04-17 15:34:36 -04:00 committed by George Psarakis
parent 075cd73206
commit 4e28c0b839
1 changed files with 6 additions and 2 deletions

View File

@ -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):