Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
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: Python support for custom ext. policies. #12418

Closed

Conversation

deivse
Copy link
Contributor

@deivse deivse commented Feb 8, 2025

This is still missing a lot. Planned for after #12416 and #12417.
Pushing this now so this can be consulted to better understand why some of the changes in #12417 are needed (the version in #12360 is quite outdated by now)

@deivse deivse force-pushed the x509_verification_py_extension_policy branch from b6e74ff to 6f646bf Compare February 8, 2025 18:09
@deivse
Copy link
Contributor Author

deivse commented Feb 8, 2025

This is missing interface definitions in x509.pyi and tests for the new API, but should otherwise be functional. Feel free to review the rust implementation in the meantime.

@deivse deivse changed the title Add public ExtensionPolicy constructors for webpki policies. x509 Verification: Python support for custom ext. policies. Feb 9, 2025
@deivse
Copy link
Contributor Author

deivse commented Feb 9, 2025

@alex This was named wrong until now. I could swear I already edited the title of this PR before and it changed back to the incorrect one... So hopefully it sticks this time 😄 This is the main PR that adds support for custom extension policies to python.

@deivse deivse force-pushed the x509_verification_py_extension_policy branch from 581ee05 to 5ef0b92 Compare February 9, 2025 16:07
@deivse
Copy link
Contributor Author

deivse commented Feb 10, 2025

@alex Do you have any ideas on how to split this up further, or is this one of the rare cases where you guys can accept a large PR? I have thought about it for a bit, but it seems pretty monolithic to me. I'm sure some things could be separated out, but none of the options seem to make much sense to me - e.g. would require to write additional tests for things that are currently tested "organically", etc.

Unfortunately I expect this to grow a bit more as more tests are needed.

@deivse deivse force-pushed the x509_verification_py_extension_policy branch 2 times, most recently from b5ec04e to 5ba8e35 Compare February 10, 2025 12:48
let py_ext = match ext {
None => None,
Some(ext) => parse_cert_ext(py, ext).map_err(|e| {
make_validation_error(format!("{e} (while converting Extension to Python object)"))
Copy link
Contributor Author

@deivse deivse Feb 10, 2025

Choose a reason for hiding this comment

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

Do you maybe have any ideas on how to handle this? This should be the last part that doesn't have coverage. I'm struggling to come up with a way to test this in a sane way, or to prove that this can not occur (and thus make this an unwrap). Suggestions much appreciated.

Copy link
Member

@alex alex left a comment

Choose a reason for hiding this comment

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

Two small-ish suggestions for additional bits to split out.

I'll try to do a more thorough review later.

src/rust/cryptography-x509-verification/src/policy/mod.rs Outdated Show resolved Hide resolved
vectors/cryptography_vectors/x509/custom/no_sans.pem Outdated Show resolved Hide resolved
@deivse deivse force-pushed the x509_verification_py_extension_policy branch from 5ba8e35 to 8aa5eb7 Compare February 10, 2025 15:22
@deivse
Copy link
Contributor Author

deivse commented Feb 10, 2025

Rebased on main.

@deivse
Copy link
Contributor Author

deivse commented Feb 10, 2025

Btw, just occurred to me that I can potentially split out the .pyi edits since that doesn't really affect anything else. But it seems weird to me to have the interface in main without the implementation.

@alex
Copy link
Member

alex commented Feb 10, 2025

Yeah, we should land the .pyi files at the same time as the implementations. Will aim to review later today.

Thanks!

@alex
Copy link
Member

alex commented Feb 11, 2025

Just realized another piece that could be split out:

Adding ExtensionPolicy, but without the methods for actually configuring it, so all you can do is create either WebPKI or allow all, and attach it to a PolicyBuilder.

That should let us get most of the structure, and then it's just the callbacks to be reviewed as the last piece. I think it roughly splits the PR in two pieces.

@deivse
Copy link
Contributor Author

deivse commented Feb 11, 2025

Just realized another piece that could be split out:

Great idea, will do!

@deivse
Copy link
Contributor Author

deivse commented Feb 11, 2025

Closing to declutter, as I already created the 2 new PRs.

@deivse deivse closed this Feb 11, 2025
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