-
Notifications
You must be signed in to change notification settings - Fork 111
Description
Currently, the certificate chain verification logic for TSA seems to assume that the provided certificate chain is ordered from Leaf → Root (i.e., end-entity first). However, in some cases — such as when the TSA certificate chain is provided from Root → Leaf — verification may fail or require manual reordering before validation. It would be helpful if the verification logic could automatically detect and handle both chain orders by matching certificates based on their issuer and subject fields, instead of relying on the array order.
Why this is useful:
Strictly speaking, according to [RFC 5652](5.1. SignedData Type), the certificate chain type is defined as SET OF rather than SEQUENCE, so the order of the chain cannot be enforced. Nonetheless, it is customary to use SEQUENCE, so there is no particular issue with the current implementation.
However, one drawback is that some external systems or APIs may present the root certificate instead of the leaf certificate as the first element in the certificate chain. Supporting both directions would make the verification process more robust and developer-friendly.