Skip to content

variant of verify_callback with additional context #29

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

Merged
merged 4 commits into from
Jun 21, 2017

Conversation

sstecko
Copy link
Contributor

@sstecko sstecko commented Jun 6, 2017

This enables the workfow where an individual needs user confirmation for a failed certificate during verification callback.

/// successful. The Ok() variant indicates a successful validation while the Err() variant
/// contains the errorcode returned from the internal verification process.
/// The validated certificate, is accessible through the second argument of the closure.
pub fn verify_callback2<F>(&mut self, callback: F) -> &mut Builder
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think we've cut a release with verify_callback so we can just update this in place.

None
}

pub fn chains(&self) -> Vec<CertChain> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should probably return an iterator rather than a vec.

None
}

pub fn get_chain(&self, index :usize) -> Option<CertChain> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We'll want some way to know how many chains there are if we have this, and the implementation shouldn't be a linear scan.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we cut the get_ prefix off of this?

impl CertValidationResult {

/// Returns the certificate that failed validation if applicable
pub fn get_failed_certificate(&self) -> Option<CertContext> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Getter functions typically omit the get_ prefix.

@sstecko
Copy link
Contributor Author

sstecko commented Jun 6, 2017

Attempted to make the changes SFackler suggested. Thanks for the review

@sstecko
Copy link
Contributor Author

sstecko commented Jun 7, 2017

@steffengy[github.com] @sfackler[github.com] I'm not sure why this check is failing, but I don't think it's due to my code change.

@steffengy
Copy link
Owner

steffengy commented Jun 7, 2017

It's just a nightly regression so that currently GCC will not be found. (for MINGW)
rust-lang/rust#42422

So you can safely ignore it, in the next few days it'll fix itself.

@sstecko
Copy link
Contributor Author

sstecko commented Jun 12, 2017

Hey guys, is there anything I need to do to push this PR forward? I'd really like to get this merge and have a release cut so I can use this with hyper-native-tls in a project :)

@@ -32,7 +33,7 @@ lazy_static! {
#[derive(Default)]
pub struct Builder {
domain: Option<Vec<u16>>,
verify_callback: Option<Arc<Fn(io::Result<()>, &CertChain) -> io::Result<()>>>,
verify_callback: Option<Arc<Fn(CertValidationResult) -> io::Result<()>>>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This needs to be passed a reference, not a result by value or it'll have access to a bunch of dangling pointers once the callback returns.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh maybe not...

res :io::Result<()>,
chain_index :i32,
element_index :i32,
extra_policy_status :Option<winapi::CERT_CHAIN_POLICY_STATUS>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like this is unused?

self.chain.final_chain()
}

pub fn result(&self) -> &io::Result<()> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

io::Error isn't Clone, so we'll want this to return the Result by value so that it can then be returned from the closure - we should probably store the error code directly and construct the Error on each call.

res :io::Result<()>,
chain_index :i32,
element_index :i32,
extra_policy_status : (winapi::LPCSTR, *const winapi::c_void),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we get rid of these fields if they aren't used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

steffengy suggested that it might be useful long-term, so I put them in and made them usable. It would be an API breaking change to add them later, but if they don't seem useful in this context I will remove them.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think it'd be breaking - they're not publicly accessible, right?

Copy link
Owner

Choose a reason for hiding this comment

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

To clarify:
I only meant to describe which struct fields could potentially be relevant for us.
Those particular fields might be relevant for some use case in the future
(when we would access them and expose them without breaking BC).

Since we currently aren't even aware of a use case,
there's no need to keep them around.

@sstecko
Copy link
Contributor Author

sstecko commented Jun 21, 2017

Hey @sfackler I have put up another revision. I appreciate your attention here, as we are somewhat blocked on getting these changes merged in and incorporated into the project.

@sfackler
Copy link
Collaborator

LGTM, thanks! I won't be able to publish until I get home to my Windows box tonight, but you should be able to unblock yourself by doing a package replacement: http://doc.crates.io/manifest.html#the-replace-section.

@steffengy
Copy link
Owner

@sfackler
I'll look into getting this merged & published within a few minutes.

@steffengy steffengy merged commit 8e1133f into steffengy:master Jun 21, 2017
@steffengy
Copy link
Owner

Published as 0.1.6.

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.

3 participants