Skip to content

Comments

x509: allow AnyExtendedKeyUsage for CA#5313

Open
furmur wants to merge 1 commit intorandombit:masterfrom
furmur:improvement/x509/any_eku_for_CA
Open

x509: allow AnyExtendedKeyUsage for CA#5313
furmur wants to merge 1 commit intorandombit:masterfrom
furmur:improvement/x509/any_eku_for_CA

Conversation

@furmur
Copy link
Contributor

@furmur furmur commented Feb 11, 2026

Resolves #5308

  • add new OID 2.5.29.37.0 = X509v3.AnyExtendedKeyUsage
  • consider X509v3.AnyExtendedKeyUsage as certificate signing compatible purpose

@coveralls
Copy link

coveralls commented Feb 11, 2026

Coverage Status

coverage: 90.049% (-0.005%) from 90.054%
when pulling f50701d on furmur:improvement/x509/any_eku_for_CA
into 6d81b0c on randombit:master.

Copy link
Collaborator

@reneme reneme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally this looks good to me, but I'm wondering if we should consider this new "any usage" in X509_Certificate::allowed_extended_usage() as well:

bool X509_Certificate::allowed_extended_usage(const OID& usage) const {
const std::vector<OID>& ex = extended_key_usage();
if(ex.empty()) {
return true;
}
if(std::find(ex.begin(), ex.end(), usage) != ex.end()) {
return true;
}
return false;
}

... essentially, if ex contains "X509v3.AnyExtendedKeyUsage" we may immediately return true and don't even bother checking the vector.

However, RFC 5280 Section 4.2.1.12 quite vaguely states:

Applications that require the presence of a particular purpose MAY reject certificates that include the anyExtendedKeyUsage OID but not the particular OID expected for the application.

However, in my opinion, if we consider "any usage" good enough for specifying a CA, we might as well consider it for other usages as well.

@furmur
Copy link
Contributor Author

furmur commented Feb 12, 2026

@reneme changed X509_Certificate::allowed_extended_usage() as well.

as for RFC vagueness, that's why i was asking in the issue #5308 whether this behavior should be covered by policy but as randombit said it already tolerates omitted extension so no big changes here.

Copy link
Collaborator

@reneme reneme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look fine to me.

Do you happen to have a certificate handy that we could place in the test suite to exercise those new checks? (Edit: just recalled that you had in fact already posted some, sorry.) Perhaps along those lines. I.e. a CA certificate that doesn't have any specific EKUs but just "any". Just place it in "src/tests/data/x509/misc" and add a test ensuring that it recognized as 1) "a CA" and 2) capable of signing CRLs, OCSPs or similar.

@furmur furmur force-pushed the improvement/x509/any_eku_for_CA branch 2 times, most recently from c95029e to c86208c Compare February 13, 2026 09:45
@furmur
Copy link
Contributor Author

furmur commented Feb 13, 2026

  1. capable of signing CRLs, OCSPs or similar.

added test. but cert is considered as not capable for OCSP because X509_Certificate::allowed_usage() uses
has_ex_constraint() instead of modified allowed_extended_usage().

maybe it's ok to leave it this way (otherwise should to modify has_ex_constraint() as well)

testing cert ku/eku:

X509v3 extensions:
    X509v3 Extended Key Usage: 
        Any Extended Key Usage
    X509v3 Key Usage: critical
        Digital Signature, Certificate Sign, CRL Sign

@reneme
Copy link
Collaborator

reneme commented Feb 13, 2026

added test. but cert is considered as not capable for OCSP because X509_Certificate::allowed_usage() uses
has_ex_constraint() instead of modified allowed_extended_usage().

I found it surprising that "PKIX.ServerAuth" and "PKIX.ClientAuth" is checked with allowed_extended_usage but "PKIX.OCSPSigning" uses has_ex_constraint. I did some digging, and that was changed in #3067 as a fix for CVE-2022-43705. I'm not 100% sure anymore but this was probably meant to enforce the existence of the extended key usage and fail when no EKU-extension is available instead of just letting it pass.

maybe it's ok to leave it this way (otherwise should to modify has_ex_constraint() as well)

I think, has_ex_constraint() should also say "yes" if the new "any" EKU is present.

@furmur furmur force-pushed the improvement/x509/any_eku_for_CA branch from c86208c to effda0a Compare February 15, 2026 19:10
* add new OID 2.5.29.37.0 = X509v3.AnyExtendedKeyUsage
* x509: is_CA_cert: consider X509v3.AnyExtendedKeyUsage as certificate signing compatible purpose
* x509: allowed_extended_usage: allow any usage if contains AnyExtendedKeyUsage
* x509: has_ex_constraint: return true if contains AnyExtendedKeyUsage
@furmur furmur force-pushed the improvement/x509/any_eku_for_CA branch from effda0a to f50701d Compare February 15, 2026 19:19
@furmur
Copy link
Contributor Author

furmur commented Feb 15, 2026

changed:

  • has_ex_constraint() to return true on X509v3.AnyExtendedKeyUsage in extended key usage oids
  • allowed_extended_usage() to use has_ex_constraint()

allowed_usage(Usage_Type::OCSP_RESPONDER) for certs with X509v3.AnyExtendedKeyUsage and without PKIX.OCSPSigning now returns true.

@furmur furmur requested a review from reneme February 19, 2026 15:00
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.

x509cert: allow anyExtendedKeyUsage (2.5.29.37.0) for CA

3 participants