Also find a possible parent, and add it to the end of the list

This commit is contained in:
Ruben van Staveren 2022-07-27 12:45:10 +02:00
parent 5c4f6d2c67
commit 5cce5722c5
Signed by: ruben
GPG Key ID: 886F6BECD477A93F

View File

@ -252,9 +252,14 @@ def order_x509(x509_objects, root_issuers):
while x509_objects:
sibling = [x for x in x509_objects
if x.get_issuer() == bundle[0].get_subject()]
parent = [x for x in x509_objects
if x.get_subject() == bundle[-1].get_issuer()]
if sibling and len(sibling) == 1:
# insert sibling at beginning of list
bundle.insert(0, x509_objects.pop(x509_objects.index(sibling[0])))
elif parent and len(parent) == 1:
# Try to place a (cross signed) intermediate at the end if it matches
bundle.append(x509_objects.pop(x509_objects.index(parent[0])))
else:
# Lets complain
logging.error('Certificates remaining data\n\t%s',