Skip to content

Commit

Permalink
Minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
njaremko committed Jun 24, 2024
1 parent 8d8ef40 commit 03879c9
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/idp/verified_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,19 @@ impl<'a> UnverifiedAuthnRequest<'a> {
})
}

pub fn get_certs_der(&self) -> Result<Vec<Vec<u8>>, Error> {
fn get_certs_der(&self) -> Result<Vec<Vec<u8>>, Error> {
let x509_certs = self
.request
.signature
.as_ref()
.ok_or(Error::NoSignature)?
.key_info
.as_ref()
.map(|ki| ki.iter().next()) // TODO: why only the first key?
.unwrap_or(None)
.map(|ki| ki.iter())
.ok_or(Error::NoKeyInfo)?
.x509_data
.iter()
.flat_map(|d| d.x509_data.as_ref())
.flat_map(|d| d.certificates.iter())
.map(|cert| crypto::decode_x509_cert(cert.as_str()))
.map(|cert| crypto::decode_x509_cert(cert))
.collect::<Result<Vec<_>, _>>()
.map_err(|_| Error::InvalidCertificateEncoding)?;

Expand All @@ -49,7 +47,7 @@ impl<'a> UnverifiedAuthnRequest<'a> {
.into_iter()
.map(|der_cert| Ok(verify_signed_xml(xml, &der_cert, Some("ID"))?))
.reduce(|a, b| a.or(b))
.unwrap()
.ok_or(Error::UnexpectedError)?
.map(|()| VerifiedAuthnRequest(self.request))
}

Expand Down

0 comments on commit 03879c9

Please sign in to comment.