Conversation
createIdentifiersUsingCSR walks csr.Extensions to collect the TNAuthList,
permanent-identifier and hardware-module identifiers, but the branch that
reads the SAN extension ends in `break`, which leaves the loop rather than
the branch. The TNAuthList check runs earlier in the same iteration, so it
only sees extensions that precede the SAN one.
x509.CreateCertificateRequest writes the SAN extension before anything in
ExtraExtensions, which is where a TNAuthList has to go. So in a CSR that
carries both, the TNAuthList identifier is silently dropped:
CSR with TNAuthList only -> [{TNAuthList ...}]
CSR with TNAuthList and DNSNames ["..."] -> [{dns ...}]
Both callers are affected. OrderParametersFromCSR builds an order that is
short one identifier, and validateOrderIdentifiers rejects an otherwise
correct order with "number of identifiers in Order ... (2) does not match
the number of identifiers extracted from CSR ... (1)".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
createIdentifiersUsingCSRwalkscsr.Extensionsto pick up the TNAuthList, permanent-identifier and hardware-module identifiers (csr.go:295, "Extract TNAuthList, permanent identifiers and hardware module values"). The branch that reads the SAN extension ends inbreak, which leaves the loop, not the branch. The TNAuthList check sits earlier in the same iteration, so it only ever sees extensions that come before the SAN one.x509.CreateCertificateRequestwrites the SAN extension (2.5.29.17) before anything inExtraExtensions, andExtraExtensionsis where a TNAuthList (1.3.6.1.5.5.7.1.26) has to go. So in any CSR that carries both, the TNAuthList identifier is dropped.Measured on
master(e289d7f), building the CSR withx509.CreateCertificateRequestand parsing it back:1.3.6.1.5.5.7.1.26[{TNAuthList MASgAgwA}]DNSNames: ["example.com"]2.5.29.17,1.3.6.1.5.5.7.1.26[{dns example.com}]— TNAuthList lostBoth callers see it:
OrderParametersFromCSR(csr.go:142, reached fromObtainCertificateForSANs) builds an order that is short one identifier, so the CA has nothing to authorize it against.validateOrderIdentifiers(client.go:235, called unconditionally from the finalize path) rejects an otherwise correct 2-identifier order with:The fix
Drop the
break. Nothing after it depends on leaving the loop early; a CSR has at most one SAN extension, so the remaining iterations only look at the other extensions this block is meant to read. With it gone, the same CSR yields[{dns example.com} {TNAuthList MASgAgwA}]andvalidateOrderIdentifiersreturns nil.Tests
New
csr_test.go(csr.gohad no test file).Test_createIdentifiersUsingCSR_tnAuthListbuilds real CSRs throughx509.CreateCertificateRequestso the extension order is the one a caller actually produces, and covers TNAuthList alone and TNAuthList next to a SAN.go test ./...passes on this branch (both packages).csr.goleaves the "TNAuthList alongside a SAN" subtest failing with[{dns example.com}], and the "TNAuthList alone" subtest passing — so the test pins the bug, not the feature.go vet ./...clean.gofmtreports no diff for either file beyond the repo's existing CRLF checkout (gofmt -lflags untouched files such asclient.gothe same way on my machine).No existing test referenced TNAuthList, which is how this survived #35 and #37.