Skip to content

Carry raw CSR subjects through signing; add unsigned roots - #1467

Merged
mitch292 merged 2 commits into
cloudflare:masterfrom
ang-cloudflare:ang/SECENG-14212-resolve-conflict
Nov 18, 2026
Merged

mitch292 merged 2 commits into
cloudflare:masterfrom
ang-cloudflare:ang/SECENG-14212-resolve-conflict

Conversation

@ang-cloudflare

Copy link
Copy Markdown
Contributor

Replaces #1466 (Luke is out of office) so it can merge without pushing to his fork.

This branch is Luke's commit a47b854 from #1466, unchanged, plus a merge of current master (cb5f8cf, which includes #1465). See #1466 for the description and review history.

The only conflict was at the end of helpers/helpers_test.go, where #1465 and #1466 both appended tests. The resolution keeps both sides and adds back the two closing braces of TestIsUnsigned. git show --remerge-diff 7973d27b shows only the resolution:

-<<<<<<< a47b8546 (Carry raw CSR subjects through signing; add unsigned roots)
 func TestIsUnsigned(t *testing.T) {
 ...
 		t.Error("IsUnsigned() = false for id-alg-unsigned")
-=======
+	}
+}
+
 func isASCIISpace(b byte) bool {
 ...
 		t.Error("ParseCSR(DER with trailing garbage) succeeded, want error")
->>>>>>> cb5f8cf8 (Merge pull request #1465 from lukevalenta/fix-parsecsr-trimspace)
 	}
 }

go vet ./helpers and go test ./helpers ./csr ./initca ./signer/... pass.

Please merge with a merge commit rather than squash, so Luke's commit keeps its authorship and message.

lukevalenta and others added 2 commits November 16, 2026 10:48
A CSR subject containing a value that pkix.Name cannot represent, such as
the RELATIVE-OID of a Trust Anchor ID name, failed to sign with "asn1:
cannot marshal nil value" because ParseCertificateRequest rebuilt the
subject from a decoded pkix.Name.

signer: RELATIVE-OID attribute values are taken from the encoded subject
when the decoded subject is built, so such a subject signs. The CSR's
subject bytes are kept only when the signing profile sets the new
KeepCSRSubject flag, which cannot be set from a configuration file.
local.Sign copies them only when the profile whitelists the subject and
clears them when the sign request overrides the subject. With a
name_whitelist, every common name of a kept raw subject must be a string
that matches. CSRs that master signs produce the same certificates unless
the flag is set.

csr: CertificateRequest.RawSubject is used verbatim as the CSR subject.
It is not read from or written to JSON or YAML, must be a structurally
valid non-empty X.501 Name (ValidateRawName), and is rejected together
with CN, Names or SerialNumber.

helpers: IsUnsigned reports the RFC 9925 id-alg-unsigned algorithm.

initca: New and NewFromSigner set KeepCSRSubject for a request with a raw
subject. RenewFromSigner carries the old subject over as encoded and
rejects unsigned roots, since renewal would produce a signed certificate.
Unsign rewrites a version 3 certificate of any kind as an RFC 9925
unsigned certificate without verifying its signature. It removes the
authority key identifier and issuer alternative name extensions and
rejects an issuer without attributes or an issuerUniqueID.
NewUnsigned and NewUnsignedFromSigner are New and NewFromSigner followed
by Unsign, without Hosts. NewUnsignedFromSigner applies req.CRL and
req.CA.Backdate as NewUnsigned does and checks the signature under the
certificate's public key before removing it.

A CA with an empty subject, which RenewFromSigner accepted before, is now
rejected because an empty Name fails the raw subject check.
@mitch292
mitch292 merged commit e67926c into cloudflare:master Nov 18, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants