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

Improve error message when trying to build_chain #140

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions src/verify_cert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,12 @@ pub fn build_chain(
Ok(()) => {
return Ok(());
},
Err(..) => {
// If the error is not fatal, then keep going.
error @ Err(..) => {
// If the error is not fatal, then keep going unless there are not intermediate certs
// then we want this more descriptive error.
if intermediate_certs.is_empty() {
return error;
}
},
}

Expand Down Expand Up @@ -321,15 +325,17 @@ where
V: IntoIterator,
F: Fn(V::Item) -> Result<(), Error>,
{
let mut error = Error::UnknownIssuer;
for v in values {
match f(v) {
Ok(()) => {
return Ok(());
},
Err(..) => {
// If the error is not fatal, then keep going.
},
}
Err(e) => {
// If the error is not fatal, then keep going recording the last error.
error = e;
}
}
}
Err(Error::UnknownIssuer)
Err(error)
}