Skip to content

Add additional x509 store verification bindings #1390

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

naleba97
Copy link

Added some low level bindings to the X509 Store builder struct for expanded verification capabilities.

Also fixed add_cert() to take in an &X509Ref instead of a X509.

@naleba97 naleba97 force-pushed the add-x509-verif-options branch 7 times, most recently from 9a3d15a to 742c7af Compare December 16, 2020 08:16
cfg_if! {
if #[cfg(any(ossl102, libressl261))] {
/// Sets the verification flags used to verify a certificate against a chain.
pub fn set_flags(&mut self, flags: X509VerifyFlags) -> Result<(), ErrorStack> {
Copy link
Owner

Choose a reason for hiding this comment

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

Why would the argument type for this not be X509VerifyFlags on old versions?

Copy link
Author

Choose a reason for hiding this comment

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

X509VerifyFlags is in the verify module which is only compiled in the top level x509 module for any(ossl102, libressl261). I could relax/remove the version condition to use X509VerifyFlags for older versions.

Copy link
Owner

Choose a reason for hiding this comment

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

If the type is used in APIs that exist in older versions, then it can be exposed on those older versions.

Copy link
Author

Choose a reason for hiding this comment

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

Removed the top-level constraint on the verify module and added more fine-grained constraints on structs and bit flags in the verify module.

}

/// Sets the purpose used to verify the certificate chain.
pub fn set_purpose(&mut self, purpose: c_int) -> Result<(), ErrorStack> {
Copy link
Owner

Choose a reason for hiding this comment

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

These should not take a raw integer.

Copy link
Author

Choose a reason for hiding this comment

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

@naleba97 naleba97 force-pushed the add-x509-verif-options branch 2 times, most recently from ac59787 to 8b4322f Compare December 18, 2020 08:19
@naleba97 naleba97 requested a review from sfackler December 25, 2020 18:38
#[cfg(not(any(ossl110)))]
pub const DEFAULT: TrustId = TrustId(ffi::X509_TRUST_DEFAULT);
#[cfg(any(ossl110))]
pub const DEFAULT: TrustId = TrustId(ffi::X509_TRUST_DEFAULT); /* Only valid in purpose settings */
Copy link
Owner

Choose a reason for hiding this comment

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

Aren't these two definitions identical?

Copy link
Author

Choose a reason for hiding this comment

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

Whoops, good catch, will remove.

@@ -58,6 +59,61 @@ bitflags! {
}
}

pub struct PurposeId(c_int);
Copy link
Owner

Choose a reason for hiding this comment

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

These seem to fit better in the store module since that's where they're actually used. I'd call them X509Purpose and X509Trust probably I think.

Copy link
Author

Choose a reason for hiding this comment

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

Sure, I originally put them in the verify module since trust and purpose values are also used in X509_VERIFY_PARAM, in addition to X509_STORE.

@eutampieri
Copy link

What’s missing in this PR? Can I do something to make it pass review?

@naleba97 naleba97 force-pushed the add-x509-verif-options branch from 9ce2a66 to 97154e4 Compare April 9, 2021 18:48
@naleba97
Copy link
Author

naleba97 commented Apr 9, 2021

Revisiting the PR: currently making fixes to build for 1.0.1

@naleba97 naleba97 force-pushed the add-x509-verif-options branch from 97154e4 to 9e9ff5e Compare April 9, 2021 19:00
@naleba97 naleba97 force-pushed the add-x509-verif-options branch from 9e9ff5e to 63be141 Compare April 9, 2021 19:05
@naleba97
Copy link
Author

naleba97 commented Apr 9, 2021

Hey @sfackler, please let me know if there's anything else blocking this PR. I've just rebased with the latest changes. Thanks!

@eutampieri
Copy link

Any update on this?

@minyung
Copy link

minyung commented Jul 13, 2022

@sfackler
I need set_purpose 😢😢. How is it going?

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.

4 participants