Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x509 Verification: ExtensionPolicy refactor. #11801

Conversation

deivse
Copy link
Contributor

@deivse deivse commented Oct 19, 2024

Another quick preliminary PR that just refactors some existing code to make implementation of user-provided extension policies more straightforward. (A good change even on it's own in my opinion.)

(
// 5280 4.2.2.1: Authority Information Access
AUTHORITY_INFORMATION_ACCESS_OID,
ExtensionValidator::maybe_present(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would be glad to hear any ideas on improving the compactness of the initialisation code here.

I considered implementing a function that accepts an argument for each of these "default" validators, but that would be extremely bug-prone since it would be order-dependent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(The github preview doesn't really make it clear what I'm talking about, so check out the full file)

pub(crate) fn new(
validator_by_oid: HashMap<asn1::ObjectIdentifier, ExtensionValidator<B>>,
) -> Self {
Self { validator_by_oid }
Copy link
Member

Choose a reason for hiding this comment

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

So this was the original design here, and we intentionally moved away from it for performance. Unless it's absolutely necessary, I'd prefer not to revert this change.

Can you explain a bit more what the motivation for this change is?

Copy link
Contributor Author

@deivse deivse Oct 19, 2024

Choose a reason for hiding this comment

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

The motivation is to be able to support custom extension types. I was initially planning to limit the scope of user-customizable extension verification to user provided callbacks, but @woodruffw said he would prefer to allow custom extension OIDs since they have a usecase for that (see #11165 (comment) and previous comments)

If performance is really such an issue with this implementation and we still want to keep the ability to define validators for arbitrary extensions, we could potentially just leave the default extension validation as is and add a map for custom extension validators.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I think named validators for the standard ones + a map for extending it sounds good.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright. What I'm not sure about though is if I should once again wait until the meat of the feature is implemented so the coverage for this is free, or if I should add some tests specific to this to the rust crate and make the PR now.

Copy link
Member

Choose a reason for hiding this comment

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

I think either approach could work, so whichever you prefer is fine. But if it were me, I'd implement the whole feature, and then if the overall patch is too large we can look at ways to split pieces out.

@deivse
Copy link
Contributor Author

deivse commented Oct 21, 2024

Closing this, will be implemented together with the other changes and split out if necessary.

@deivse deivse closed this Oct 21, 2024
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.

2 participants