Skip to content

Preserve CSR extensions during simpleenroll - #65

Merged
jjrdk merged 3 commits into
jjrdk:masterfrom
LorenzoSchumacher:fix/simpleenroll-csr-extensions
Sep 1, 2026
Merged

Preserve CSR extensions during simpleenroll#65
jjrdk merged 3 commits into
jjrdk:masterfrom
LorenzoSchumacher:fix/simpleenroll-csr-extensions

Conversation

@LorenzoSchumacher

@LorenzoSchumacher LorenzoSchumacher commented Sep 1, 2026

Copy link
Copy Markdown

Fixes #64

Problem

SimpleEnrollHandler.HandleProfile calls CertificateRequest.LoadSigningRequest without
CertificateRequestLoadOptions.UnsafeLoadCertificateExtensions, so the parsed CSR's
CertificateExtensions is always empty. SignCertificateRequest copies extensions from that
CertificateRequest, so any extension requested in the CSR (SAN, KeyUsage, EKU, ...) is silently
dropped from the certificate issued via /simpleenroll.

SimpleReEnrollHandler and ServerKeyGenHandler already pass this flag - this brings
SimpleEnrollHandler in line with them.

Fix

Add the missing CertificateRequestLoadOptions.UnsafeLoadCertificateExtensions flag to the
LoadSigningRequest call in SimpleEnrollHandler.

Tests

Added two Scenario Outlines (rsa + ecdsa) to EstServer.feature, verified red before the fix and
green after:

  • "Enrollment honors the extensions requested in the CSR" - asserts the issued certificate's
    KeyUsage extension matches what was requested.
  • "Enrollment honors the subject alternative name URI requested in the CSR" - builds a raw CSR with a
    SubjectAlternativeNameBuilder.AddUri SAN entry (since EstClient.Enroll has no API for custom SAN
    extensions) and asserts it survives /simpleenroll intact. This reproduces the real-world case
    described in the linked issue.

Also ran the full opencertserver.certserver.tests suite to confirm no regressions - the 67
pre-existing failures there are unrelated ACME/CertesSlim issues, unaffected by this change.

Lorenzo Schumacher added 3 commits September 1, 2026 10:12
…simpleenroll

Adds an EST server scenario that submits a CSR requesting a specific
X509KeyUsageExtension and asserts the issued certificate carries that
same extension. This currently fails because SimpleEnrollHandler loads
the CSR without CertificateRequestLoadOptions.UnsafeLoadCertificateExtensions,
silently dropping all CSR extensions before the certificate is signed.
CertificateRequest.LoadSigningRequest defaults to
CertificateRequestLoadOptions.Default, which does not populate
CertificateExtensions from the parsed CSR. Because SignCertificateRequest
copies extensions from the CertificateRequest it is given, this caused
all CSR extensions (SAN, KeyUsage, EKU, etc.) requested via
/simpleenroll to be silently dropped from the issued certificate.

SimpleReEnrollHandler and ServerKeyGenHandler already pass
CertificateRequestLoadOptions.UnsafeLoadCertificateExtensions; this
brings SimpleEnrollHandler in line with them.

Fixes the failing scenario added in the previous commit.
@jjrdk
jjrdk merged commit ee1e0f2 into jjrdk:master Sep 1, 2026
5 checks passed
@jjrdk

jjrdk commented Sep 1, 2026

Copy link
Copy Markdown
Owner

That does seem like an oversight. Thank you for the contribution.

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.

/simpleenroll silently drops all CSR extensions (SAN, KeyUsage, etc.)

2 participants