diff --git a/sort_certificate.py b/sort_certificate.py index 98c32dd..582bec7 100755 --- a/sort_certificate.py +++ b/sort_certificate.py @@ -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',