we are using String here, because else we run into lifetime issues.
(cert: &str)
| 96 | |
| 97 | // we are using String here, because else we run into lifetime issues. |
| 98 | fn read_algo(cert: &str) -> Result<&'static SignatureAlgorithm> { |
| 99 | let cert = pem::parse(cert).context("Parse PEM")?; |
| 100 | let (_remainder, x509) = |
| 101 | x509_parser::parse_x509_certificate(cert.contents()).context("Parse x509")?; |
| 102 | |
| 103 | let alg_oid = x509 |
| 104 | .signature_algorithm |
| 105 | .algorithm |
| 106 | .iter() |
| 107 | .ok_or_else(|| anyhow!("Parse certificate error"))? |
| 108 | .collect::<Vec<_>>(); |
| 109 | Ok(SignatureAlgorithm::from_oid(&alg_oid)?) |
| 110 | } |