Skip to content

Strengthen validation of end-entity key usage when present#15018

Open
sjudson wants to merge 3 commits into
pyca:mainfrom
trail-of-forks:sj/keyusage
Open

Strengthen validation of end-entity key usage when present#15018
sjudson wants to merge 3 commits into
pyca:mainfrom
trail-of-forks:sj/keyusage

Conversation

@sjudson

@sjudson sjudson commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

This PR aligns the default behavior of the server and client certificate verifiers with modern CABF requirements. Along with the existing negative check that keyCertSign is not set, we add the requirement that digitalSignature is.

As before, this default validation can be overridden by way of the ExtensionPolicy interface.

@alex alex requested a review from woodruffw June 12, 2026 16:10

@woodruffw woodruffw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @sjudson!


if !key_usage.digital_signature() {
return Err(ValidationError::new(ValidationErrorKind::Other(
"EE keyUsage must assert digitalSignature when present".to_string(),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

At this point we have a keyUsage, so "when present" feels redundant 🙂

Suggested change
"EE keyUsage must assert digitalSignature when present".to_string(),
"EE keyUsage must assert digitalSignature".to_string(),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've cut this.

)));
}

if !key_usage.digital_signature() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Note: CABF 7.1.2.7.11 requires digitalSignature for subscriber certs (i.e. EEs) that convey ECC keys, but does not require it for subscriber certs that convey RSA keys:

Image

This is an incredible mess in practice: the BR says that an RSA-conveying subscriber cert MUST have at least one keyUsage, but no specific one is a MUST in practice unless the validator knows the TLS version being used.

Given that, I think we have two options here:

  1. Continue to just enforce digitalSignature. This...probably works fine in practice, even though it's technically stricter than what the BRs say?
  2. Differentiate this check based on the subscriber's key type: for ECC keys it should be the current check, while for RSA keys it should at be at least one of digitalSignature | keyEncipherment | dataEncipherment.

Curious what @alex and @reaperhulk think about this as well 🙂

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I guess I'm still unsure if we want to enforce this at all, or if we want to allow configuring it on the policy builder? (Or just require users to provide their own extension validator for KU)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it makes sense to enforce in our default policy, since we're otherwise relatively strict about CABF (and the limbo results suggest that other validators check this). But it is indeed somewhat annoying to enforce correctly.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we know if the other validators are key-type aware?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we know if the other validators are key-type aware?

Didn't test that yet, will do so tonight 🙂

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes the word "modern" was doing perhaps a bit too much heavy lifting in my initial description.

I've now added distinct handling for RSA that considers keyEncipherment sufficient (and allows both, despite being NOT RECOMMENDED) to be more permissive for the default validation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants