Skip to content

Commit

Permalink
refactor: use find_map instead of filter_map
Browse files Browse the repository at this point in the history
  • Loading branch information
picoHz committed May 7, 2024
1 parent e7021ba commit bdb3980
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions taxy/src/certs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,11 @@ impl Cert {
let parsed_chain = parse_chain(&certs)?;
let x509 = parsed_chain.first().ok_or(Error::FailedToReadCertificate)?;

let common_name = x509
.subject()
.iter_common_name()
.filter_map(|name| {
name.as_str()
.ok()
.and_then(|name| SubjectName::from_str(name).ok())
})
.next();
let common_name = x509.subject().iter_common_name().find_map(|name| {
name.as_str()
.ok()
.and_then(|name| SubjectName::from_str(name).ok())
});

let san = common_name
.clone()
Expand Down

0 comments on commit bdb3980

Please sign in to comment.